diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-31 14:52:07 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-31 14:52:07 +0000 |
commit | 9295fb20b77e303a0a0c00df77cca917000de18c (patch) | |
tree | 617aa2c05dac9b88154cf6790732ac31696ce045 /spec | |
parent | 3deb879ff25c2c85bae29e8e820e8cd135662b2b (diff) | |
parent | bf0fd497bf3370edd7bbaf8c3421ff333719d004 (diff) | |
download | gitlab-ce-9295fb20b77e303a0a0c00df77cca917000de18c.tar.gz |
Merge branch '395-fix-notification-when-group-set-to-watch' into 'master'
Fix notification when group set to watch
Closes #395
See merge request !8883
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/notification_service_spec.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 309985a5d90..7cf2cd9968f 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -443,6 +443,8 @@ describe NotificationService, services: true do before do build_team(issue.project) + build_group(issue.project) + add_users_with_subscription(issue.project, issue) reset_delivered_emails! update_custom_notification(:new_issue, @u_guest_custom, project) @@ -459,6 +461,8 @@ describe NotificationService, services: true do should_email(@u_guest_custom) should_email(@u_custom_global) should_email(@u_participant_mentioned) + should_email(@g_global_watcher) + should_email(@g_watcher) should_not_email(@u_mentioned) should_not_email(@u_participating) should_not_email(@u_disabled) @@ -1218,6 +1222,22 @@ describe NotificationService, services: true do project.add_master(@u_custom_global) end + # Users in the project's group but not part of project's team + # with different notification settings + def build_group(project) + group = create(:group, :public) + project.group = group + + # Group member: global=disabled, group=watch + @g_watcher = create_user_with_notification(:watch, 'group_watcher', project.group) + @g_watcher.notification_settings_for(nil).disabled! + + # Group member: global=watch, group=global + @g_global_watcher = create_global_setting_for(create(:user), :watch) + group.add_users([@g_watcher, @g_global_watcher], :master) + group + end + def create_global_setting_for(user, level) setting = user.global_notification_setting setting.level = level @@ -1226,9 +1246,9 @@ describe NotificationService, services: true do user end - def create_user_with_notification(level, username) + def create_user_with_notification(level, username, resource = project) user = create(:user, username: username) - setting = user.notification_settings_for(project) + setting = user.notification_settings_for(resource) setting.level = level setting.save |