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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
30a4f4c9
Commit
30a4f4c9
authored
Jan 15, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This will ensure previous assignee gets an email even if his notif level is "on mention"
parent
55ae5394
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
5 deletions
+44
-5
app/services/notification_service.rb
app/services/notification_service.rb
+4
-5
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+40
-0
No files found.
app/services/notification_service.rb
View file @
30a4f4c9
...
@@ -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
,
action: :reassign
,
extra_recipients:
[
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,11 +400,9 @@ class NotificationService
...
@@ -400,11 +400,9 @@ class NotificationService
end
end
end
end
def
build_recipients
(
target
,
project
,
current_user
,
action:
nil
,
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
)
...
@@ -412,6 +410,7 @@ class NotificationService
...
@@ -412,6 +410,7 @@ class NotificationService
# new assignee to the list of recipients after we rejected users with
# new assignee to the list of recipients after we rejected users with
# the "on mention" notification level
# the "on mention" notification level
if
action
==
:reassign
if
action
==
:reassign
recipients
<<
previous_assignee
if
previous_assignee
recipients
<<
target
.
assignee
recipients
<<
target
.
assignee
end
end
...
...
spec/services/notification_service_spec.rb
View file @
30a4f4c9
...
@@ -227,6 +227,46 @@ describe NotificationService, services: true do
...
@@ -227,6 +227,46 @@ describe NotificationService, services: true do
end
end
describe
:reassigned_issue
do
describe
:reassigned_issue
do
it
'emails new assignee'
do
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
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 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
it
'emails new assignee'
do
issue
.
update_attribute
(
:assignee
,
@u_mentioned
)
issue
.
update_attribute
(
:assignee
,
@u_mentioned
)
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
notification
.
reassigned_issue
(
issue
,
@u_disabled
)
...
...
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