Skip to content

Commit

Permalink
added test to check that there are no duplicated notifications for us…
Browse files Browse the repository at this point in the history
…er who belongs to several groups
  • Loading branch information
yrudman committed Aug 28, 2018
1 parent af75cbc commit cfede26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spec/models/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
expect(user.unseen_notifications.count).to eq(1)
end

it 'creates single record in notification_reciepients table if recipent user belongs to several groups' do
user.miq_groups << FactoryGirl.create(:miq_group, :tenant => tenant)
expect(subject.recipients).to match_array([user])
end

context 'asynchronous notifications' do
before { stub_settings(:server => {:asynchronous_notifications => async}) }
context 'enabled' do
Expand Down
6 changes: 5 additions & 1 deletion spec/models/notification_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end
end

describe '#subscribers' do
describe '#subscribers_ids' do
let(:user1) { FactoryGirl.create(:user) }
let(:tenant2) { FactoryGirl.create(:tenant) }
let!(:user2) { FactoryGirl.create(:user_with_group, :tenant => tenant2) }
Expand All @@ -38,6 +38,10 @@
it 'returns the users in the tenant same tenant as concerned vm' do
is_expected.to match_array([user2.id])
end
it "returns single id if user belongs to different group" do
user2.miq_groups << FactoryGirl.create(:miq_group, :tenant => tenant2)
is_expected.to match_array([user2.id])
end
end
end
end

0 comments on commit cfede26

Please sign in to comment.