-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move create_service_provision_request into MiqAeServiceMethods for consistency #34
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,5 +162,32 @@ def category_create_script | |
ct.reload | ||
expect(ct.entries.collect(&:name).include?('fred')).to be_truthy | ||
end | ||
|
||
context "#create_service_provision_request" do | ||
let(:options) { {:fred => :flintstone} } | ||
let(:svc_options) { {:dialog_style => "medium"} } | ||
let(:user) { FactoryGirl.create(:user_with_group) } | ||
let(:template) { FactoryGirl.create(:service_template_ansible_playbook) } | ||
let(:miq_request) { FactoryGirl.create(:service_template_provision_request) } | ||
let(:svc_template) do | ||
MiqAeMethodService::MiqAeServiceServiceTemplate.find(template.id) | ||
end | ||
let(:workspace) do | ||
double("MiqAeEngine::MiqAeWorkspaceRuntime", | ||
:root => options, | ||
:persist_state_hash => {}, | ||
:ae_user => user) | ||
end | ||
let(:miq_ae_service) { MiqAeService.new(workspace) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to add the namespace to the class: |
||
|
||
it "create service request" do | ||
allow(workspace).to receive(:disable_rbac) | ||
expect(svc_template).to receive(:instance_variable_get).with('@object').and_return(template) | ||
expect(template).to receive(:provision_request).with(user, svc_options).and_return(miq_request) | ||
|
||
result = miq_ae_service.execute(:create_service_provision_reques, svc_template, svc_options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fdupont-redhat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch @mkanoor. Any thoughts on why the test is failing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mkanoor, aka. Hawk Eye ;) it "#create_service_provision_request" do
options = {:fred => :flinstone}
svc_options = {:dialog_style => "medium"}
template = FactoryGirl.create(:service_template_ansible_playbook)
miq_request = FactoryGirl.create(:service_template_provision_request)
svc_template = MiqAeMethodService::MiqAeServiceServiceTemplate.find(template.id)
workspace = double("MiqAeEngine::MiqAeWorkspaceRuntime", :root => options, :persist_state_hash => {}, :ae_user => @user)
#miq_ae_service = MiqAeMethodService.new(workspace)
allow(workspace).to receive(:disable_rbac)
expect(svc_template).to receive(:instance_variable_get).with('@object').and_return(template)
expect(template).to receive(:service_provision_request).with(@user, svc_options).and_return(miq_request)
result = invoke_ae.execute(:create_service_provision_request, svc_template.inspect, svc_options.inspect)
expect(result).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqRequest)
end But invoke_ae doesn't really give undefined method `execute' for #<MiqAeEngine::MiqAeWorkspaceRuntime:0x0000000e3db518> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is probably why there is no test for What do you think @gmcculloug, @mkanoor ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should get things moving for the test: it "create service request" do
allow(workspace).to receive(:disable_rbac)
expect_any_instance_of(ServiceTemplate).to receive(:provision_request).with(user, svc_options).and_return(miq_request)
result = miq_ae_service.execute(:create_service_provision_request, svc_template, svc_options)
expect(result).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqRequest)
end |
||
expect(result).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqRequest) | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method has to change a bit more now that it is running under a different class. Since we do not have access to
@workspace
we can get the user from theUser.current_user
set but the calling methodexecute
here.