Commit 8bb15838 authored by Athar Hameed's avatar Athar Hameed Committed by Sean McGivern

[EE] Fix unassign slash command preview

parent 687f5788
......@@ -139,8 +139,10 @@ module QuickActions
'Remove assignee'
end
end
explanation do
"Removes #{'assignee'.pluralize(issuable.assignees.size)} #{issuable.assignees.map(&:to_reference).to_sentence}."
explanation do |users = nil|
assignees = issuable.assignees
assignees &= users if users.present? && issuable.allows_multiple_assignees?
"Removes #{'assignee'.pluralize(assignees.size)} #{assignees.map(&:to_reference).to_sentence}."
end
params do
issuable.allows_multiple_assignees? ? '@user1 @user2' : ''
......
---
title: Fix unassign slash command preview
merge_request: 18447
author:
type: fixed
......@@ -4,6 +4,7 @@ describe QuickActions::InterpretService do
let(:user) { create(:user) }
let(:developer) { create(:user) }
let(:developer2) { create(:user) }
let(:developer3) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:service) { described_class.new(project, developer) }
......@@ -115,4 +116,39 @@ describe QuickActions::InterpretService do
end
end
end
describe '#explain' do
describe 'unassign command' do
let(:content) { '/unassign' }
let(:issue) { create(:issue, project: project, assignees: [developer, developer2]) }
it "includes all assignees' references" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Removes assignees @#{developer.username} and @#{developer2.username}."])
end
end
describe 'unassign command with assignee references' do
let(:content) { "/unassign @#{developer.username} @#{developer3.username}" }
let(:issue) { create(:issue, project: project, assignees: [developer, developer2, developer3]) }
it 'includes only selected assignee references' do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Removes assignees @#{developer.username} and @#{developer3.username}."])
end
end
describe 'unassign command with non-existent assignee reference' do
let(:content) { "/unassign @#{developer.username} @#{developer3.username}" }
let(:issue) { create(:issue, project: project, assignees: [developer, developer2]) }
it 'ignores non-existent assignee references' do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Removes assignee @#{developer.username}."])
end
end
end
end
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