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
9b7bf3af
Commit
9b7bf3af
authored
Mar 19, 2021
by
David Kim
Committed by
Gabriel Mazetto
Mar 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Localize assignees and reviewers label
parent
f264588c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
6 deletions
+79
-6
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+3
-3
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+2
-3
locale/gitlab.pot
locale/gitlab.pot
+20
-0
spec/helpers/issuables_helper_spec.rb
spec/helpers/issuables_helper_spec.rb
+54
-0
No files found.
app/helpers/issuables_helper.rb
View file @
9b7bf3af
...
@@ -20,13 +20,13 @@ module IssuablesHelper
...
@@ -20,13 +20,13 @@ module IssuablesHelper
end
end
def
assignees_label
(
issuable
,
include_value:
true
)
def
assignees_label
(
issuable
,
include_value:
true
)
label
=
'Assignee'
.
pluralize
(
issuable
.
assignees
.
count
)
assignees
=
issuable
.
assignees
if
include_value
if
include_value
sanitized_list
=
sanitize_name
(
issuable
.
assignee_list
)
sanitized_list
=
sanitize_name
(
issuable
.
assignee_list
)
"
#{
label
}
:
#{
sanitized_list
}
"
ns_
(
'NotificationEmail|Assignee: %{users}'
,
'NotificationEmail|Assignees: %{users}'
,
assignees
.
count
)
%
{
users:
sanitized_list
}
else
else
label
ns_
(
'NotificationEmail|Assignee'
,
'NotificationEmail|Assignees'
,
assignees
.
count
)
end
end
end
end
...
...
app/helpers/merge_requests_helper.rb
View file @
9b7bf3af
...
@@ -176,13 +176,12 @@ module MergeRequestsHelper
...
@@ -176,13 +176,12 @@ module MergeRequestsHelper
def
reviewers_label
(
merge_request
,
include_value:
true
)
def
reviewers_label
(
merge_request
,
include_value:
true
)
reviewers
=
merge_request
.
reviewers
reviewers
=
merge_request
.
reviewers
reviewer_label
=
'Reviewer'
.
pluralize
(
reviewers
.
count
)
if
include_value
if
include_value
sanitized_list
=
sanitize_name
(
reviewers
.
map
(
&
:name
).
to_sentence
)
sanitized_list
=
sanitize_name
(
reviewers
.
map
(
&
:name
).
to_sentence
)
"
#{
reviewer_label
}
:
#{
sanitized_list
}
"
ns_
(
'NotificationEmail|Reviewer: %{users}'
,
'NotificationEmail|Reviewers: %{users}'
,
reviewers
.
count
)
%
{
users:
sanitized_list
}
else
else
reviewer_label
ns_
(
'NotificationEmail|Reviewer'
,
'NotificationEmail|Reviewers'
,
reviewers
.
count
)
end
end
end
end
...
...
locale/gitlab.pot
View file @
9b7bf3af
...
@@ -21062,6 +21062,26 @@ msgstr ""
...
@@ -21062,6 +21062,26 @@ msgstr ""
msgid "Notification settings saved"
msgid "Notification settings saved"
msgstr ""
msgstr ""
msgid "NotificationEmail|Assignee"
msgid_plural "NotificationEmail|Assignees"
msgstr[0] ""
msgstr[1] ""
msgid "NotificationEmail|Assignee: %{users}"
msgid_plural "NotificationEmail|Assignees: %{users}"
msgstr[0] ""
msgstr[1] ""
msgid "NotificationEmail|Reviewer"
msgid_plural "NotificationEmail|Reviewers"
msgstr[0] ""
msgstr[1] ""
msgid "NotificationEmail|Reviewer: %{users}"
msgid_plural "NotificationEmail|Reviewers: %{users}"
msgstr[0] ""
msgstr[1] ""
msgid "NotificationEvent|Change reviewer merge request"
msgid "NotificationEvent|Change reviewer merge request"
msgstr ""
msgstr ""
...
...
spec/helpers/issuables_helper_spec.rb
View file @
9b7bf3af
...
@@ -44,6 +44,60 @@ RSpec.describe IssuablesHelper do
...
@@ -44,6 +44,60 @@ RSpec.describe IssuablesHelper do
end
end
end
end
describe
'#assignees_label'
do
let
(
:issuable
)
{
build
(
:merge_request
)
}
let
(
:assignee1
)
{
build_stubbed
(
:user
,
name:
'Jane Doe'
)
}
let
(
:assignee2
)
{
build_stubbed
(
:user
,
name:
'John Doe'
)
}
before
do
allow
(
issuable
).
to
receive
(
:assignees
).
and_return
(
assignees
)
end
context
'when multiple assignees exist'
do
let
(
:assignees
)
{
[
assignee1
,
assignee2
]
}
it
'returns assignee label with assignee names'
do
expect
(
helper
.
assignees_label
(
issuable
)).
to
eq
(
"Assignees: Jane Doe and John Doe"
)
end
it
'returns assignee label only with include_value: false'
do
expect
(
helper
.
assignees_label
(
issuable
,
include_value:
false
)).
to
eq
(
"Assignees"
)
end
context
'when the name contains a URL'
do
let
(
:assignees
)
{
[
build_stubbed
(
:user
,
name:
'www.gitlab.com'
)]
}
it
'returns sanitized name'
do
expect
(
helper
.
assignees_label
(
issuable
)).
to
eq
(
"Assignee: www_gitlab_com"
)
end
end
end
context
'when one assignee exists'
do
let
(
:assignees
)
{
[
assignee1
]
}
it
'returns assignee label with no names'
do
expect
(
helper
.
assignees_label
(
issuable
)).
to
eq
(
"Assignee: Jane Doe"
)
end
it
'returns assignee label only with include_value: false'
do
expect
(
helper
.
assignees_label
(
issuable
,
include_value:
false
)).
to
eq
(
"Assignee"
)
end
end
context
'when no assignees exist'
do
let
(
:assignees
)
{
[]
}
it
'returns assignee label with no names'
do
expect
(
helper
.
assignees_label
(
issuable
)).
to
eq
(
"Assignees: "
)
end
it
'returns assignee label only with include_value: false'
do
expect
(
helper
.
assignees_label
(
issuable
,
include_value:
false
)).
to
eq
(
"Assignees"
)
end
end
end
describe
'#issuable_meta'
do
describe
'#issuable_meta'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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