Skip to content

Commit

Permalink
Merge pull request ManageIQ#18471 from d-m-u/fixing_red_master_servic…
Browse files Browse the repository at this point in the history
…e_retirement_specs

raise_retirement_event called with user object should expect the user info
  • Loading branch information
Fryguy authored Feb 20, 2019
2 parents 1680ffb + 209ba99 commit 2665784
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spec/models/service/retirement_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,32 @@
end

describe "#raise_retirement_event " do
before do
User.super_admin || FactoryBot.create(:user, :userid => 'admin', :role => 'super_administrator')
end

it "without user" do
event_name = 'foo'
event_hash = {:userid => nil, :service => @service, :type => "Service"}
expect(MiqEvent).to receive(:raise_evm_event).with(@service, event_name, event_hash, {})
@service.raise_retirement_event(event_name)
end

it "with user" do
it "with string user" do
event_name = 'foo'
event_hash = {:userid => "admin", :service => @service, :type => "Service"}
expect(MiqEvent).to receive(:raise_evm_event).with(@service, event_name, event_hash, :user_id => user.id, :group_id => user.current_group.id, :tenant_id => user.current_tenant.id)
expect(MiqEvent).to receive(:raise_evm_event).with(@service, event_name, event_hash, :user_id => User.find_by(:userid => "admin").id, :group_id => User.find_by(:userid => "admin").current_group.id, :tenant_id => User.find_by(:userid => "admin").current_tenant.id)
@service.raise_retirement_event(event_name, "admin")
end

it "with user that isn't found" do
it "with user object" do
event_name = 'foo'
event_hash = {:userid => user, :service => @service, :type => "Service"}
expect(MiqEvent).to receive(:raise_evm_event).with(@service, event_name, event_hash, :user_id => user.id, :group_id => user.current_group.id, :tenant_id => user.current_tenant.id)
@service.raise_retirement_event(event_name, user)
end

it "with string user that isn't found" do
event_name = 'foo'
event_hash = {:userid => "nonexistent_username", :service => @service, :type => "Service"}
expect(MiqEvent).to receive(:raise_evm_event).with(@service, event_name, event_hash, {})
Expand Down

0 comments on commit 2665784

Please sign in to comment.