Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bf0fd497
Commit
bf0fd497
authored
Oct 18, 2016
by
amaia
Committed by
Rémy Coutable
Jan 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix notification when global=disabled, group=watch
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
6aec85ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
app/services/notification_service.rb
app/services/notification_service.rb
+4
-4
changelogs/unreleased/395-fix-notification-when-group-set-to-watch.yml
...released/395-fix-notification-when-group-set-to-watch.yml
+4
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+22
-2
No files found.
app/services/notification_service.rb
View file @
bf0fd497
...
...
@@ -365,7 +365,7 @@ class NotificationService
users
=
users_with_global_level_watch
([
users_with_project_level_global
,
users_with_group_level_global
].
flatten
.
uniq
)
users_with_project_setting
=
select_project_member_setting
(
project
,
users_with_project_level_global
,
users
)
users_with_group_setting
=
select_group_member_setting
(
project
,
project_members
,
users_with_group_level_global
,
users
)
users_with_group_setting
=
select_group_member_setting
(
project
.
group
,
project_members
,
users_with_group_level_global
,
users
)
User
.
where
(
id:
users_with_project_setting
.
concat
(
users_with_group_setting
).
uniq
).
to_a
end
...
...
@@ -415,8 +415,8 @@ class NotificationService
end
# Build a list of users based on group notification settings
def
select_group_member_setting
(
project
,
project_members
,
global_setting
,
users_global_level_watch
)
uids
=
notification_settings_for
(
project
,
:watch
)
def
select_group_member_setting
(
group
,
project_members
,
global_setting
,
users_global_level_watch
)
uids
=
notification_settings_for
(
group
,
:watch
)
# Group setting is watch, add to users list if user is not project member
users
=
[]
...
...
@@ -473,7 +473,7 @@ class NotificationService
setting
=
user
.
notification_settings_for
(
project
)
if
!
setting
&&
project
.
group
if
project
.
group
&&
(
setting
.
nil?
||
setting
.
global?
)
setting
=
user
.
notification_settings_for
(
project
.
group
)
end
...
...
changelogs/unreleased/395-fix-notification-when-group-set-to-watch.yml
0 → 100644
View file @
bf0fd497
---
title
:
Fix notifications when set at group level
merge_request
:
6813
author
:
Alexandre Maia
spec/services/notification_service_spec.rb
View file @
bf0fd497
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment