Skip to content

Commit

Permalink
Change the role from ems_operations to automate for the MiqQueue.put
Browse files Browse the repository at this point in the history
 of Service Template Provision Request create_request_tasks.

https://bugzilla.redhat.com/show_bug.cgi?id=1534068
  • Loading branch information
tinaafitz committed Apr 13, 2018
1 parent 0086f71 commit 905d525
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/miq_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def execute
:instance_id => id,
:method_name => "create_request_tasks",
:zone => options.fetch(:miq_zone, my_zone),
:role => my_role,
:role => kind_of?(ServiceTemplateProvisionRequest) ? 'automate' : my_role,
:tracking_label => tracking_label_id,
:msg_timeout => 3600,
:deliver_on => deliver_on
Expand Down
32 changes: 32 additions & 0 deletions spec/models/miq_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,38 @@ def approvals
end
end

context '#execute' do
shared_examples_for "#calls create_request_tasks with the proper role" do
it "runs successfully" do
expect(request).to receive(:approved?).and_return(true)
expect(MiqQueue.count).to eq(0)

request.execute
expect(MiqQueue.count).to eq(1)
expect(MiqQueue.first.role).to eq(role)
end
end

context 'Service provisioning' do
let(:request) { FactoryGirl.create(:service_template_provision_request, :approval_state => 'approved', :requester => fred) }
let(:role) { 'automate' }

context "uses the automate role" do
it_behaves_like "#calls create_request_tasks with the proper role"
end
end

context 'VM provisioning' do
let(:template) { FactoryGirl.create(:template_vmware, :ext_management_system => FactoryGirl.create(:ems_vmware_with_authentication)) }
let(:request) { FactoryGirl.build(:miq_provision_request, :requester => fred, :src_vm_id => template.id).tap(&:valid?) }
let(:role) { 'ems_operations' }

context "uses the ems_operations role" do
it_behaves_like "#calls create_request_tasks with the proper role"
end
end
end

context '#post_create_request_tasks' do
context 'VM provisioning' do
before do
Expand Down

0 comments on commit 905d525

Please sign in to comment.