Commit 66b297c8 authored by Sean McGivern's avatar Sean McGivern

Merge branch '332594-allow-severity-quickaction-on-create' into 'master'

Allow usage of severity quickaction on create

See merge request gitlab-org/gitlab!67380
parents 9b310f62 a503a456
......@@ -246,14 +246,20 @@ module Gitlab
params '1 / S1 / Critical'
types Issue
condition do
quick_action_target.supports_severity?
!quick_action_target.persisted? || quick_action_target.supports_severity?
end
parse_params do |severity|
find_severity(severity)
end
command :severity do |severity|
next unless quick_action_target.supports_severity?
if severity
::Issues::UpdateService.new(project: quick_action_target.project, current_user: current_user, params: { severity: severity }).execute(quick_action_target)
if quick_action_target.persisted?
::Issues::UpdateService.new(project: quick_action_target.project, current_user: current_user, params: { severity: severity }).execute(quick_action_target)
else
quick_action_target.build_issuable_severity(severity: severity)
end
@execution_message[:severity] = _("Severity updated to %{severity}.") % { severity: severity.capitalize }
else
......
......@@ -2096,6 +2096,19 @@ RSpec.describe QuickActions::InterpretService do
end
end
context 'when quick action is used on creation' do
let(:content) { '/severity s3' }
let(:issuable) { build(:incident, project: project) }
it_behaves_like 'updates the severity', 'medium'
context 'issuable does not support severity' do
let(:issuable) { build(:issue, project: project) }
it_behaves_like 'failed command', ''
end
end
context 'severity given with S format' do
let(:content) { '/severity s3' }
......
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