summaryrefslogtreecommitdiff
path: root/spec/models/notification_recipient_spec.rb
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2018-05-28 15:43:46 -0300
committerFelipe Artur <felipefac@gmail.com>2018-06-07 15:47:39 -0300
commitafe5d7d56ee771dac6e4a97d23e69d678c03da2d (patch)
treed4852e794d3c526863eb2ff0bd3d7f399cd40de1 /spec/models/notification_recipient_spec.rb
parent439adb96dadd49124d080db0db0b0076d2049c6b (diff)
downloadgitlab-ce-afe5d7d56ee771dac6e4a97d23e69d678c03da2d.tar.gz
Apply notification settings level of groups to all child objects
Diffstat (limited to 'spec/models/notification_recipient_spec.rb')
-rw-r--r--spec/models/notification_recipient_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/notification_recipient_spec.rb b/spec/models/notification_recipient_spec.rb
index eda0e1da835..13fe47799ed 100644
--- a/spec/models/notification_recipient_spec.rb
+++ b/spec/models/notification_recipient_spec.rb
@@ -13,4 +13,48 @@ describe NotificationRecipient do
expect(recipient.has_access?).to be_falsy
end
+
+ context '#notification_setting' do
+ context 'for child groups', :nested_groups do
+ let!(:moved_group) { create(:group) }
+ let(:group) { create(:group) }
+ let(:sub_group_1) { create(:group, parent: group) }
+ let(:sub_group_2) { create(:group, parent: sub_group_1) }
+ let(:project) { create(:project, namespace: moved_group) }
+
+ before do
+ sub_group_2.add_owner(user)
+ moved_group.add_owner(user)
+ Groups::TransferService.new(moved_group, user).execute(sub_group_2)
+
+ moved_group.reload
+ end
+
+ context 'when notification setting is global' do
+ before do
+ user.notification_settings_for(group).global!
+ user.notification_settings_for(sub_group_1).mention!
+ user.notification_settings_for(sub_group_2).global!
+ user.notification_settings_for(moved_group).global!
+ end
+
+ it 'considers notification setting from the first parent without global setting' do
+ expect(subject.notification_setting.source).to eq(sub_group_1)
+ end
+ end
+
+ context 'when notification setting is not global' do
+ before do
+ user.notification_settings_for(group).global!
+ user.notification_settings_for(sub_group_1).mention!
+ user.notification_settings_for(sub_group_2).watch!
+ user.notification_settings_for(moved_group).disabled!
+ end
+
+ it 'considers notification setting from lowest group member in hierarchy' do
+ expect(subject.notification_setting.source).to eq(moved_group)
+ end
+ end
+ end
+ end
end