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
68c15872
Commit
68c15872
authored
Mar 02, 2021
by
David Kim
Committed by
Luke Duncalfe
Mar 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reviewer information to new merge request email notification
parent
fe676e7b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
0 deletions
+76
-0
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+12
-0
app/views/notify/new_merge_request_email.html.haml
app/views/notify/new_merge_request_email.html.haml
+2
-0
app/views/notify/new_merge_request_email.text.erb
app/views/notify/new_merge_request_email.text.erb
+1
-0
changelogs/unreleased/300750-merge-request-email-notifications-don-t-include-reviewer-informati.yml
...-email-notifications-don-t-include-reviewer-informati.yml
+5
-0
spec/helpers/merge_requests_helper_spec.rb
spec/helpers/merge_requests_helper_spec.rb
+53
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+3
-0
No files found.
app/helpers/merge_requests_helper.rb
View file @
68c15872
...
@@ -174,6 +174,18 @@ module MergeRequestsHelper
...
@@ -174,6 +174,18 @@ module MergeRequestsHelper
end
end
end
end
def
reviewers_label
(
merge_request
,
include_value:
true
)
reviewers
=
merge_request
.
reviewers
reviewer_label
=
'Reviewer'
.
pluralize
(
reviewers
.
count
)
if
include_value
sanitized_list
=
sanitize_name
(
reviewers
.
map
(
&
:name
).
to_sentence
)
"
#{
reviewer_label
}
:
#{
sanitized_list
}
"
else
reviewer_label
end
end
private
private
def
review_requested_merge_requests_count
def
review_requested_merge_requests_count
...
...
app/views/notify/new_merge_request_email.html.haml
View file @
68c15872
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
Author:
#{
@merge_request
.
author_name
}
Author:
#{
@merge_request
.
author_name
}
.assignee
.assignee
=
assignees_label
(
@merge_request
)
=
assignees_label
(
@merge_request
)
.reviewer
=
reviewers_label
(
@merge_request
)
.approvers
.approvers
=
render_if_exists
'notify/merge_request_approvers'
,
presenter:
@mr_presenter
=
render_if_exists
'notify/merge_request_approvers'
,
presenter:
@mr_presenter
...
...
app/views/notify/new_merge_request_email.text.erb
View file @
68c15872
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<%=
merge_path_description
(
@merge_request
,
'to'
)
%>
<%=
merge_path_description
(
@merge_request
,
'to'
)
%>
<%=
'Author:'
%>
<%=
@merge_request
.
author_name
%>
<%=
'Author:'
%>
<%=
@merge_request
.
author_name
%>
<%=
assignees_label
(
@merge_request
)
if
@merge_request
.
assignees
.
any?
%>
<%=
assignees_label
(
@merge_request
)
if
@merge_request
.
assignees
.
any?
%>
<%=
reviewers_label
(
@merge_request
)
if
@merge_request
.
reviewers
.
any?
%>
<%=
render_if_exists
'notify/merge_request_approvers'
,
presenter:
@mr_presenter
%>
<%=
render_if_exists
'notify/merge_request_approvers'
,
presenter:
@mr_presenter
%>
<%=
@merge_request
.
description
%>
<%=
@merge_request
.
description
%>
changelogs/unreleased/300750-merge-request-email-notifications-don-t-include-reviewer-informati.yml
0 → 100644
View file @
68c15872
---
title
:
Add reviewers detail to new merge request email
merge_request
:
54781
author
:
type
:
added
spec/helpers/merge_requests_helper_spec.rb
View file @
68c15872
...
@@ -90,4 +90,57 @@ RSpec.describe MergeRequestsHelper do
...
@@ -90,4 +90,57 @@ RSpec.describe MergeRequestsHelper do
)
)
end
end
end
end
describe
'#reviewers_label'
do
let
(
:merge_request
)
{
build_stubbed
(
:merge_request
)
}
let
(
:reviewer1
)
{
build_stubbed
(
:user
,
name:
'Jane Doe'
)
}
let
(
:reviewer2
)
{
build_stubbed
(
:user
,
name:
'John Doe'
)
}
before
do
allow
(
merge_request
).
to
receive
(
:reviewers
).
and_return
(
reviewers
)
end
context
'when multiple reviewers exist'
do
let
(
:reviewers
)
{
[
reviewer1
,
reviewer2
]
}
it
'returns reviewer label with reviewer names'
do
expect
(
helper
.
reviewers_label
(
merge_request
)).
to
eq
(
"Reviewers: Jane Doe and John Doe"
)
end
it
'returns reviewer label only with include_value: false'
do
expect
(
helper
.
reviewers_label
(
merge_request
,
include_value:
false
)).
to
eq
(
"Reviewers"
)
end
context
'when the name contains a URL'
do
let
(
:reviewers
)
{
[
build_stubbed
(
:user
,
name:
'www.gitlab.com'
)]
}
it
'returns sanitized name'
do
expect
(
helper
.
reviewers_label
(
merge_request
)).
to
eq
(
"Reviewer: www_gitlab_com"
)
end
end
end
context
'when one reviewer exists'
do
let
(
:reviewers
)
{
[
reviewer1
]
}
it
'returns reviewer label with no names'
do
expect
(
helper
.
reviewers_label
(
merge_request
)).
to
eq
(
"Reviewer: Jane Doe"
)
end
it
'returns reviewer label only with include_value: false'
do
expect
(
helper
.
reviewers_label
(
merge_request
,
include_value:
false
)).
to
eq
(
"Reviewer"
)
end
end
context
'when no reviewers exist'
do
let
(
:reviewers
)
{
[]
}
it
'returns reviewer label with no names'
do
expect
(
helper
.
reviewers_label
(
merge_request
)).
to
eq
(
"Reviewers: "
)
end
it
'returns reviewer label only with include_value: false'
do
expect
(
helper
.
reviewers_label
(
merge_request
,
include_value:
false
)).
to
eq
(
"Reviewers"
)
end
end
end
end
end
spec/mailers/notify_spec.rb
View file @
68c15872
...
@@ -16,12 +16,14 @@ RSpec.describe Notify do
...
@@ -16,12 +16,14 @@ RSpec.describe Notify do
let_it_be
(
:user
,
reload:
true
)
{
create
(
:user
)
}
let_it_be
(
:user
,
reload:
true
)
{
create
(
:user
)
}
let_it_be
(
:current_user
,
reload:
true
)
{
create
(
:user
,
email:
"current@email.com"
,
name:
'www.example.com'
)
}
let_it_be
(
:current_user
,
reload:
true
)
{
create
(
:user
,
email:
"current@email.com"
,
name:
'www.example.com'
)
}
let_it_be
(
:assignee
,
reload:
true
)
{
create
(
:user
,
email:
'assignee@example.com'
,
name:
'John Doe'
)
}
let_it_be
(
:assignee
,
reload:
true
)
{
create
(
:user
,
email:
'assignee@example.com'
,
name:
'John Doe'
)
}
let_it_be
(
:reviewer
,
reload:
true
)
{
create
(
:user
,
email:
'reviewer@example.com'
,
name:
'Jane Doe'
)
}
let_it_be
(
:merge_request
)
do
let_it_be
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
target_project:
project
,
author:
current_user
,
author:
current_user
,
assignees:
[
assignee
],
assignees:
[
assignee
],
reviewers:
[
reviewer
],
description:
'Awesome description'
)
description:
'Awesome description'
)
end
end
...
@@ -342,6 +344,7 @@ RSpec.describe Notify do
...
@@ -342,6 +344,7 @@ RSpec.describe Notify do
is_expected
.
to
have_body_text
(
project_merge_request_path
(
project
,
merge_request
))
is_expected
.
to
have_body_text
(
project_merge_request_path
(
project
,
merge_request
))
is_expected
.
to
have_body_text
(
merge_request
.
source_branch
)
is_expected
.
to
have_body_text
(
merge_request
.
source_branch
)
is_expected
.
to
have_body_text
(
merge_request
.
target_branch
)
is_expected
.
to
have_body_text
(
merge_request
.
target_branch
)
is_expected
.
to
have_body_text
(
reviewer
.
name
)
end
end
end
end
...
...
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