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

Set issue type when creating incident issues

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