Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-03-19 06:09:30 +00:00
parent 88be36271c
commit 0f26d7c7fb
4 changed files with 79 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -21074,6 +21074,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 ""

View File

@ -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) }