Commit bc886f7f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'pl-hide-quick-actions-incident' into 'master'

Hide `/epic` and `/remove_epic` for unsupported issuables

See merge request gitlab-org/gitlab!40509
parents ad06f01c 737901db
......@@ -12,7 +12,8 @@ module EE
explanation _('Adds an issue to an epic.')
types Issue
condition do
quick_action_target.project.group&.feature_available?(:epics) &&
quick_action_target.supports_epic? &&
quick_action_target.project.group&.feature_available?(:epics) &&
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end
params '<&epic | group&epic | Epic URL>'
......@@ -42,6 +43,7 @@ module EE
types Issue
condition do
quick_action_target.persisted? &&
quick_action_target.supports_epic? &&
quick_action_target.project.group&.feature_available?(:epics) &&
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end
......
......@@ -52,6 +52,20 @@ RSpec.describe Notes::QuickActionsService do
end
end
context 'on an incident' do
before do
issue.update!(issue_type: :incident)
end
it 'leaves the note empty' do
expect(execute(note)).to be_empty
end
it 'does not assigns the issue to the epic' do
expect { execute(note) }.not_to change { issue.reload.epic }
end
end
context 'on a merge request' do
let(:note_mr) { create(:note_on_merge_request, project: project, note: note_text) }
......@@ -97,6 +111,16 @@ RSpec.describe Notes::QuickActionsService do
end
end
context 'on an incident' do
before do
issue.update!(issue_type: :incident)
end
it 'leaves the note empty' do
expect(execute(note)).to be_empty
end
end
context 'on a merge request' do
let(:note_mr) { create(:note_on_merge_request, project: project, note: note_text) }
......
......@@ -362,6 +362,16 @@ RSpec.describe QuickActions::InterpretService do
expect(message).to eq("Issue #{issue.to_reference} has already been added to epic #{epic.to_reference}.")
end
end
context 'when issuable does not support epics' do
it 'does not assign an incident to an epic' do
incident = create(:incident, project: project)
_, updates = service.execute(content, incident)
expect(updates).to be_empty
end
end
end
context 'when epic does not exist' do
......@@ -720,13 +730,18 @@ RSpec.describe QuickActions::InterpretService do
context 'remove_epic command' do
let(:epic) { create(:epic, group: group) }
let(:content) { "/remove_epic #{epic.to_reference(project)}" }
let(:content) { "/remove_epic" }
before do
stub_licensed_features(epics: true)
issue.update!(epic: epic)
end
context 'when epics are disabled' do
before do
stub_licensed_features(epics: false)
end
it 'does not recognize /remove_epic' do
_, updates = service.execute(content, issue)
......@@ -745,6 +760,16 @@ RSpec.describe QuickActions::InterpretService do
expect(updates).to eq(epic: nil)
end
end
context 'when issuable does not support epics' do
it 'does not recognize /remove_epic' do
incident = create(:incident, project: project, epic: epic)
_, updates = service.execute(content, incident)
expect(updates).to be_empty
end
end
end
context 'approve command' do
......
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