Commit 1cd8aa09 authored by Felipe Artur's avatar Felipe Artur

Fix wrong message when adding same epic to issue

Fix misleading success message when adding a
duplicate issue to epic via quick action.
parent 978b6d23
---
title: 'Show the proper message when adding a duplicate issue to an epic'
merge_request:
author: 20175
type: fixed
......@@ -18,13 +18,20 @@ module EE
params '<&epic | group&epic | Epic URL>'
command :epic do |epic_param|
epic = extract_epic(epic_param)
issue = quick_action_target
if epic && current_user.can?(:read_epic, epic)
@updates[:epic] = epic
message = _('Added an issue to an epic.')
else
message = _("This epic does not exist or you don't have sufficient permission.")
end
message =
if epic && current_user.can?(:read_epic, epic)
if issue&.epic == epic
_('Issue %{issue_reference} has already been added to epic %{epic_reference}.') %
{ issue_reference: issue.to_reference, epic_reference: epic.to_reference }
else
@updates[:epic] = epic
_('Added an issue to an epic.')
end
else
_("This epic does not exist or you don't have sufficient permission.")
end
@execution_message[:epic] = message
end
......
......@@ -241,6 +241,17 @@ describe QuickActions::InterpretService do
expect(updates).to be_empty
end
end
context 'when issue is already added to epic' do
it 'returns error message' do
issue = create(:issue, project: project, epic: epic)
_, updates, message = service.execute(content, issue)
expect(updates).to be_empty
expect(message).to eq("Issue #{issue.to_reference} has already been added to epic #{epic.to_reference}.")
end
end
end
context 'when epic does not exist' do
......
......@@ -9650,6 +9650,9 @@ msgstr ""
msgid "Issue"
msgstr ""
msgid "Issue %{issue_reference} has already been added to epic %{epic_reference}."
msgstr ""
msgid "Issue Boards"
msgstr ""
......
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