Commit 93872da0 authored by Sean Arnold's avatar Sean Arnold

Set issue type when creating incident issues

parent 81fb0963
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module IncidentManagement module IncidentManagement
module Incidents module Incidents
class CreateService < BaseService class CreateService < BaseService
ISSUE_TYPE = 'incident'
def initialize(project, current_user, title:, description:) def initialize(project, current_user, title:, description:)
super(project, current_user) super(project, current_user)
...@@ -16,7 +18,8 @@ module IncidentManagement ...@@ -16,7 +18,8 @@ module IncidentManagement
current_user, current_user,
title: title, title: title,
description: description, description: description,
label_ids: [find_or_create_incident_label.id] label_ids: [find_or_create_incident_label.id],
issue_type: ISSUE_TYPE
).execute ).execute
return error(issue.errors.full_messages.to_sentence, issue) unless issue.valid? return error(issue.errors.full_messages.to_sentence, issue) unless issue.valid?
......
...@@ -66,7 +66,7 @@ module Issues ...@@ -66,7 +66,7 @@ module Issues
def whitelisted_issue_params def whitelisted_issue_params
base_params = [:title, :description, :confidential] base_params = [:title, :description, :confidential]
admin_params = [:milestone_id] admin_params = [:milestone_id, :issue_type]
if can?(current_user, :admin_issue, project) if can?(current_user, :admin_issue, project)
params.slice(*(base_params + admin_params)) params.slice(*(base_params + admin_params))
......
---
title: Sets issue type for incident issues to incident
merge_request: 37781
author:
type: added
...@@ -25,12 +25,14 @@ RSpec.describe IncidentManagement::Incidents::CreateService do ...@@ -25,12 +25,14 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
it 'created issue has correct attributes' do it 'created issue has correct attributes' do
create_incident create_incident
aggregate_failures do
expect(new_issue.title).to eq(title) expect(new_issue.title).to eq(title)
expect(new_issue.description).to eq(description) expect(new_issue.description).to eq(description)
expect(new_issue.author).to eq(user) expect(new_issue.author).to eq(user)
expect(new_issue.issue_type).to eq('incident')
expect(new_issue.labels.map(&:title)).to eq([label_title]) expect(new_issue.labels.map(&:title)).to eq([label_title])
end end
end
context 'when incident label does not exists' do context 'when incident label does not exists' do
it 'creates incident label' do it 'creates incident label' 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