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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
52124655
Commit
52124655
authored
Jan 19, 2016
by
Douwe Maan
Committed by
Robert Speicher
Jan 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'fix-consider-re-assign-as-a-mention'
parent
21a2942d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
9 deletions
+71
-9
CHANGELOG
CHANGELOG
+1
-0
app/services/notification_service.rb
app/services/notification_service.rb
+13
-8
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+57
-1
No files found.
CHANGELOG
View file @
52124655
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.4.0 (unreleased)
v 8.4.0 (unreleased)
- Ensure Gravatar host looks like an actual host
- Ensure Gravatar host looks like an actual host
- Consider re-assign as a mention from a notification point of view
- Add pagination headers to already paginated API resources
- Add pagination headers to already paginated API resources
- Properly generate diff of orphan commits, like the first commit in a repository
- Properly generate diff of orphan commits, like the first commit in a repository
- Improve the consistency of commit titles, branch names, tag names, issue/MR titles, on their respective project pages
- Improve the consistency of commit titles, branch names, tag names, issue/MR titles, on their respective project pages
...
...
app/services/notification_service.rb
View file @
52124655
...
@@ -376,10 +376,10 @@ class NotificationService
...
@@ -376,10 +376,10 @@ class NotificationService
end
end
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
previous_assignee_id
=
previous_record
(
target
,
"assignee_id"
)
previous_assignee_id
=
previous_record
(
target
,
'assignee_id'
)
previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
recipients
=
build_recipients
(
target
,
project
,
current_user
,
[
previous_assignee
]
)
recipients
=
build_recipients
(
target
,
project
,
current_user
,
action: :reassign
,
previous_assignee:
previous_assignee
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
mailer
.
send
(
mailer
.
send
(
...
@@ -400,22 +400,27 @@ class NotificationService
...
@@ -400,22 +400,27 @@ class NotificationService
end
end
end
end
def
build_recipients
(
target
,
project
,
current_user
,
extra_recipients
=
nil
)
def
build_recipients
(
target
,
project
,
current_user
,
action:
nil
,
previous_assignee:
nil
)
recipients
=
target
.
participants
(
current_user
)
recipients
=
target
.
participants
(
current_user
)
recipients
=
recipients
.
concat
(
extra_recipients
).
compact
.
uniq
if
extra_recipients
recipients
=
add_project_watchers
(
recipients
,
project
)
recipients
=
add_project_watchers
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
reject_muted_users
(
recipients
,
project
)
# Re-assign is considered as a mention of the new assignee so we add the
# new assignee to the list of recipients after we rejected users with
# the "on mention" notification level
if
action
==
:reassign
recipients
<<
previous_assignee
if
previous_assignee
recipients
<<
target
.
assignee
end
recipients
=
reject_muted_users
(
recipients
,
project
)
recipients
=
add_subscribed_users
(
recipients
,
target
)
recipients
=
add_subscribed_users
(
recipients
,
target
)
recipients
=
reject_unsubscribed_users
(
recipients
,
target
)
recipients
=
reject_unsubscribed_users
(
recipients
,
target
)
recipients
.
delete
(
current_user
)
recipients
.
delete
(
current_user
)
recipients
=
recipients
.
uniq
recipients
recipients
.
uniq
end
end
def
mailer
def
mailer
...
...
spec/services/notification_service_spec.rb
View file @
52124655
...
@@ -227,7 +227,7 @@ describe NotificationService, services: true do
...
@@ -227,7 +227,7 @@ describe NotificationService, services: true do
end
end
describe
:reassigned_issue
do
describe
:reassigned_issue
do
it
'
should email
new assignee'
do
it
'
emails
new assignee'
do
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
should_email
(
issue
.
assignee
)
should_email
(
issue
.
assignee
)
...
@@ -238,6 +238,62 @@ describe NotificationService, services: true do
...
@@ -238,6 +238,62 @@ describe NotificationService, services: true do
should_not_email
(
@u_participating
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_disabled
)
end
end
it
'emails previous assignee even if he has the "on mention" notif level'
do
issue
.
update_attribute
(
:assignee
,
@u_mentioned
)
issue
.
update_attributes
(
assignee:
@u_watcher
)
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
should_email
(
@u_mentioned
)
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
end
it
'emails new assignee even if he has the "on mention" notif level'
do
issue
.
update_attributes
(
assignee:
@u_mentioned
)
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
expect
(
issue
.
assignee
).
to
be
@u_mentioned
should_email
(
issue
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
end
it
'emails new assignee'
do
issue
.
update_attribute
(
:assignee
,
@u_mentioned
)
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
expect
(
issue
.
assignee
).
to
be
@u_mentioned
should_email
(
issue
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
end
it
'does not email new assignee if they are the current user'
do
issue
.
update_attribute
(
:assignee
,
@u_mentioned
)
notification
.
reassigned_issue
(
issue
,
@u_mentioned
)
expect
(
issue
.
assignee
).
to
be
@u_mentioned
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_not_email
(
issue
.
assignee
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
end
end
end
describe
:close_issue
do
describe
:close_issue
do
...
...
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