Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
88be36271c
commit
0f26d7c7fb
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -21074,6 +21074,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 ""
|
||||||
|
|
||||||
|
|
|
@ -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) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue