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
iv
gitlab-ce
Commits
fa9004c7
Commit
fa9004c7
authored
Jul 30, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send notification to all participants when MR is merged.
parent
1e4b3264
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
41 deletions
+16
-41
CHANGELOG
CHANGELOG
+1
-0
app/services/notification_service.rb
app/services/notification_service.rb
+9
-40
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+6
-1
No files found.
CHANGELOG
View file @
fa9004c7
...
@@ -19,6 +19,7 @@ v 7.14.0 (unreleased)
...
@@ -19,6 +19,7 @@ v 7.14.0 (unreleased)
- Add fetch command to the MR page
- Add fetch command to the MR page
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
- Add fetch command to the MR page.
- Add fetch command to the MR page.
- Send notification to all participants when MR is merged.
v 7.13.2
v 7.13.2
- Fix randomly failed spec
- Fix randomly failed spec
...
...
app/services/notification_service.rb
View file @
fa9004c7
...
@@ -70,12 +70,6 @@ class NotificationService
...
@@ -70,12 +70,6 @@ class NotificationService
reassign_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'reassigned_merge_request_email'
)
reassign_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'reassigned_merge_request_email'
)
end
end
# When we close a merge request we should send next emails:
#
# * merge_request author if their notification level is not Disabled
# * merge_request assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
#
def
close_mr
(
merge_request
,
current_user
)
def
close_mr
(
merge_request
,
current_user
)
close_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'closed_merge_request_email'
)
close_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'closed_merge_request_email'
)
end
end
...
@@ -84,26 +78,8 @@ class NotificationService
...
@@ -84,26 +78,8 @@ class NotificationService
reopen_resource_email
(
issue
,
issue
.
project
,
current_user
,
'issue_status_changed_email'
,
'reopened'
)
reopen_resource_email
(
issue
,
issue
.
project
,
current_user
,
'issue_status_changed_email'
,
'reopened'
)
end
end
# When we merge a merge request we should send next emails:
#
# * merge_request author if their notification level is not Disabled
# * merge_request assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
#
def
merge_mr
(
merge_request
,
current_user
)
def
merge_mr
(
merge_request
,
current_user
)
recipients
=
[
merge_request
.
author
,
merge_request
.
assignee
]
close_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'merged_merge_request_email'
)
recipients
=
add_project_watchers
(
recipients
,
merge_request
.
target_project
)
recipients
=
reject_muted_users
(
recipients
,
merge_request
.
target_project
)
recipients
=
add_subscribed_users
(
recipients
,
merge_request
)
recipients
=
reject_unsubscribed_users
(
recipients
,
merge_request
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
merged_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
current_user
.
id
)
end
end
end
def
reopen_mr
(
merge_request
,
current_user
)
def
reopen_mr
(
merge_request
,
current_user
)
...
@@ -364,8 +340,7 @@ class NotificationService
...
@@ -364,8 +340,7 @@ class NotificationService
end
end
def
new_resource_email
(
target
,
project
,
method
)
def
new_resource_email
(
target
,
project
,
method
)
recipients
=
build_recipients
(
target
,
project
)
recipients
=
build_recipients
(
target
,
project
,
target
.
author
)
recipients
.
delete
(
target
.
author
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
)
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
)
...
@@ -373,8 +348,7 @@ class NotificationService
...
@@ -373,8 +348,7 @@ class NotificationService
end
end
def
close_resource_email
(
target
,
project
,
current_user
,
method
)
def
close_resource_email
(
target
,
project
,
current_user
,
method
)
recipients
=
build_recipients
(
target
,
project
)
recipients
=
build_recipients
(
target
,
project
,
current_user
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
current_user
.
id
)
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
current_user
.
id
)
...
@@ -383,8 +357,7 @@ class NotificationService
...
@@ -383,8 +357,7 @@ class NotificationService
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
assignee_id_was
=
previous_record
(
target
,
"assignee_id"
)
assignee_id_was
=
previous_record
(
target
,
"assignee_id"
)
recipients
=
build_recipients
(
target
,
project
)
recipients
=
build_recipients
(
target
,
project
,
current_user
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
assignee_id_was
,
current_user
.
id
)
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
assignee_id_was
,
current_user
.
id
)
...
@@ -392,21 +365,15 @@ class NotificationService
...
@@ -392,21 +365,15 @@ class NotificationService
end
end
def
reopen_resource_email
(
target
,
project
,
current_user
,
method
,
status
)
def
reopen_resource_email
(
target
,
project
,
current_user
,
method
,
status
)
recipients
=
build_recipients
(
target
,
project
)
recipients
=
build_recipients
(
target
,
project
,
current_user
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
status
,
current_user
.
id
)
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
status
,
current_user
.
id
)
end
end
end
end
def
build_recipients
(
target
,
project
)
def
build_recipients
(
target
,
project
,
current_user
)
recipients
=
recipients
=
target
.
participants
(
current_user
)
if
target
.
respond_to?
(
:participants
)
target
.
participants
else
[
target
.
author
,
target
.
assignee
]
end
recipients
=
add_project_watchers
(
recipients
,
project
)
recipients
=
add_project_watchers
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
...
@@ -415,6 +382,8 @@ class NotificationService
...
@@ -415,6 +382,8 @@ class NotificationService
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
recipients
end
end
...
...
spec/services/notification_service_spec.rb
View file @
fa9004c7
...
@@ -300,7 +300,7 @@ describe NotificationService do
...
@@ -300,7 +300,7 @@ describe NotificationService do
describe
'Merge Requests'
do
describe
'Merge Requests'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:merge_request
)
{
create
:merge_request
,
source_project:
project
,
assignee:
create
(
:user
)
}
let
(
:merge_request
)
{
create
:merge_request
,
source_project:
project
,
assignee:
create
(
:user
)
,
description:
'cc @participant'
}
before
do
before
do
build_team
(
merge_request
.
target_project
)
build_team
(
merge_request
.
target_project
)
...
@@ -311,6 +311,7 @@ describe NotificationService do
...
@@ -311,6 +311,7 @@ describe NotificationService do
it
do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
new_merge_request
(
merge_request
,
@u_disabled
)
notification
.
new_merge_request
(
merge_request
,
@u_disabled
)
...
@@ -329,6 +330,7 @@ describe NotificationService do
...
@@ -329,6 +330,7 @@ describe NotificationService do
it
do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
...
@@ -349,6 +351,7 @@ describe NotificationService do
...
@@ -349,6 +351,7 @@ describe NotificationService do
it
do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
...
@@ -369,6 +372,7 @@ describe NotificationService do
...
@@ -369,6 +372,7 @@ describe NotificationService do
it
do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
...
@@ -389,6 +393,7 @@ describe NotificationService do
...
@@ -389,6 +393,7 @@ describe NotificationService do
it
do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_participating
.
id
)
...
...
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