Skip to content

Commit

Permalink
added rspec covering User#check_reference invoked from :before_destro…
Browse files Browse the repository at this point in the history
…y callback
  • Loading branch information
yrudman committed Feb 21, 2019
1 parent ca181e0 commit 6540d00
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,18 @@
expect(user.regional_users).to match_array([user, regional_user])
end
end

describe "#check_reference" do
let(:user) { FactoryBot.create(:user) }

it "invoked from 'before_destroy' callback" do
expect(user).to receive(:check_reference)
user.destroy
end

it "throws 'abort' if reference to this user present in miq_requests table" do
FactoryBot.create(:vm_migrate_request, :requester => user)
expect { user.check_reference }.to throw_symbol(:abort)
end
end
end

0 comments on commit 6540d00

Please sign in to comment.