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
49189664
Commit
49189664
authored
Jan 16, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send unapproval emails for MRs
parent
85697bec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
3 deletions
+58
-3
app/mailers/emails/merge_requests.rb
app/mailers/emails/merge_requests.rb
+11
-2
app/services/notification_service.rb
app/services/notification_service.rb
+9
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+38
-0
No files found.
app/mailers/emails/merge_requests.rb
View file @
49189664
...
...
@@ -54,11 +54,20 @@ module Emails
mail_answer_thread
(
@merge_request
,
merge_request_thread_options
(
updated_by_user_id
,
recipient_id
))
end
def
approved_merge_request_email
(
recipient_id
,
merge_request_id
,
updat
ed_by_user_id
)
def
approved_merge_request_email
(
recipient_id
,
merge_request_id
,
approv
ed_by_user_id
)
setup_merge_request_mail
(
merge_request_id
,
recipient_id
)
@approved_by
=
User
.
find
(
approved_by_user_id
)
@approved_by_users
=
@merge_request
.
approved_by_users
.
map
(
&
:name
)
mail_answer_thread
(
@merge_request
,
merge_request_thread_options
(
updated_by_user_id
,
recipient_id
))
mail_answer_thread
(
@merge_request
,
merge_request_thread_options
(
approved_by_user_id
,
recipient_id
))
end
def
unapproved_merge_request_email
(
recipient_id
,
merge_request_id
,
unapproved_by_user_id
)
setup_merge_request_mail
(
merge_request_id
,
recipient_id
)
@unapproved_by
=
User
.
find
(
approved_by_user_id
)
@unapproved_by_users
=
@merge_request
.
approved_by_users
.
map
(
&
:name
)
mail_answer_thread
(
@merge_request
,
merge_request_thread_options
(
approved_by_user_id
,
recipient_id
))
end
def
resolved_all_discussions_email
(
recipient_id
,
merge_request_id
,
resolved_by_user_id
)
...
...
app/services/notification_service.rb
View file @
49189664
...
...
@@ -163,7 +163,7 @@ class NotificationService
end
def
unapprove_mr
(
merge_request
,
current_user
)
# TODO: send unapproval email
unapprove_mr_email
(
merge_request
,
merge_request
.
target_project
,
current_user
)
end
def
resolve_all_discussions
(
merge_request
,
current_user
)
...
...
@@ -612,6 +612,14 @@ class NotificationService
end
end
def
unapprove_mr_email
(
merge_request
,
project
,
current_user
)
recipients
=
build_recipients
(
merge_request
,
project
,
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
unapproved_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
current_user
.
id
).
deliver_later
end
end
def
add_mr_approvers_email
(
merge_request
,
approvers
,
current_user
)
approvers
.
each
do
|
approver
|
recipient
=
approver
.
user
...
...
spec/mailers/notify_spec.rb
View file @
49189664
...
...
@@ -405,6 +405,44 @@ describe Notify do
end
end
describe
'that are unapproved'
do
let
(
:last_unapprover
)
{
create
(
:user
)
}
subject
{
Notify
.
unapproved_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
last_unapprover
.
id
)
}
before
do
merge_request
.
approvals
.
create
(
user:
merge_request
.
assignee
)
end
it_behaves_like
'a multiple recipients email'
it_behaves_like
'an answer to an existing thread with reply-by-email enabled'
do
let
(
:model
)
{
merge_request
}
end
it_behaves_like
'it should show Gmail Actions View Merge request link'
it_behaves_like
'an unsubscribeable thread'
it
'is sent as the last unapprover'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
expect
(
sender
.
display_name
).
to
eq
(
last_unapprover
.
name
)
expect
(
sender
.
address
).
to
eq
(
gitlab_sender
)
end
it
'has the correct subject'
do
is_expected
.
to
have_subject
/
#{
merge_request
.
title
}
\(
#{
merge_request
.
to_reference
}
\)/
end
it
'contains the new status'
do
is_expected
.
to
have_body_text
/unapproved/i
end
it
'contains a link to the merge request'
do
is_expected
.
to
have_body_text
/
#{
namespace_project_merge_request_path
project
.
namespace
,
project
,
merge_request
}
/
end
it
'contains the names of all of the approvers'
do
is_expected
.
to
have_body_text
/
#{
merge_request
.
assignee
.
name
}
/
end
end
describe
'that are merged'
do
subject
{
Notify
.
merged_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
merge_author
.
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