Commit 9b7bf3af authored by David Kim's avatar David Kim Committed by Gabriel Mazetto

Localize assignees and reviewers label

parent f264588c
......@@ -20,13 +20,13 @@ module IssuablesHelper
end
def assignees_label(issuable, include_value: true)
label = 'Assignee'.pluralize(issuable.assignees.count)
assignees = issuable.assignees
if include_value
sanitized_list = sanitize_name(issuable.assignee_list)
"#{label}: #{sanitized_list}"
ns_('NotificationEmail|Assignee: %{users}', 'NotificationEmail|Assignees: %{users}', assignees.count) % { users: sanitized_list }
else
label
ns_('NotificationEmail|Assignee', 'NotificationEmail|Assignees', assignees.count)
end
end
......
......@@ -176,13 +176,12 @@ module MergeRequestsHelper
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}"
ns_('NotificationEmail|Reviewer: %{users}', 'NotificationEmail|Reviewers: %{users}', reviewers.count) % { users: sanitized_list }
else
reviewer_label
ns_('NotificationEmail|Reviewer', 'NotificationEmail|Reviewers', reviewers.count)
end
end
......
......@@ -21062,6 +21062,26 @@ msgstr ""
msgid "Notification settings saved"
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"
msgstr ""
......
......@@ -44,6 +44,60 @@ RSpec.describe IssuablesHelper do
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
let(:user) { create(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment