Commit aa836cbb authored by Kerri Miller's avatar Kerri Miller

Merge branch 'sy-create-incidents-via-graphql' into 'master'

Add support for creating/modifying different issue types via GraphQL API

See merge request gitlab-org/gitlab!60747
parents a3889650 0e726483
......@@ -22,6 +22,11 @@ module Mutations
as: :discussion_locked,
required: false,
description: copy_field_description(Types::IssueType, :discussion_locked)
argument :type, Types::IssueTypeEnum,
as: :issue_type,
required: false,
description: copy_field_description(Types::IssueType, :type)
end
end
end
......
---
title: Add support for creating/modifying different issue types via GraphQL API
merge_request: 60747
author:
type: added
......@@ -1188,6 +1188,7 @@ Input type: `CreateIssueInput`
| <a id="mutationcreateissuemilestoneid"></a>`milestoneId` | [`MilestoneID`](#milestoneid) | The ID of the milestone to assign to the issue. On update milestone will be removed if set to null. |
| <a id="mutationcreateissueprojectpath"></a>`projectPath` | [`ID!`](#id) | Project full path the issue is associated with. |
| <a id="mutationcreateissuetitle"></a>`title` | [`String!`](#string) | Title of the issue. |
| <a id="mutationcreateissuetype"></a>`type` | [`IssueType`](#issuetype) | Type of the issue. |
| <a id="mutationcreateissueweight"></a>`weight` | [`Int`](#int) | The weight of the issue. |
#### Fields
......@@ -3893,6 +3894,7 @@ Input type: `UpdateIssueInput`
| <a id="mutationupdateissueremovelabelids"></a>`removeLabelIds` | [`[ID!]`](#id) | The IDs of labels to be removed from the issue. |
| <a id="mutationupdateissuestateevent"></a>`stateEvent` | [`IssueStateEvent`](#issuestateevent) | Close or reopen an issue. |
| <a id="mutationupdateissuetitle"></a>`title` | [`String`](#string) | Title of the issue. |
| <a id="mutationupdateissuetype"></a>`type` | [`IssueType`](#issuetype) | Type of the issue. |
| <a id="mutationupdateissueweight"></a>`weight` | [`Int`](#int) | The weight of the issue. |
#### Fields
......
......@@ -19,7 +19,8 @@ RSpec.describe Mutations::Issues::Create do
description: 'new description',
confidential: true,
due_date: Date.tomorrow,
discussion_locked: true
discussion_locked: true,
issue_type: 'issue'
}
end
......@@ -93,6 +94,16 @@ RSpec.describe Mutations::Issues::Create do
expect(mutated_issue.iid).not_to eq(special_params[:iid])
end
end
context 'when creating a non-default issue type' do
before do
mutation_params[:issue_type] = 'incident'
end
it 'creates issue with correct values' do
expect(mutated_issue.issue_type).to eq('incident')
end
end
end
context 'when creating an issue as owner' do
......
......@@ -128,6 +128,14 @@ RSpec.describe Mutations::Issues::Update do
expect(issue.reload.labels).to match_array([project_label, label_2])
end
end
context 'when changing type' do
it 'changes the type of the issue' do
mutation_params[:issue_type] = 'incident'
expect { subject }.to change { issue.reload.issue_type }.from('issue').to('incident')
end
end
end
end
end
......@@ -20,7 +20,8 @@ RSpec.describe 'Create an issue' do
'title' => 'new title',
'description' => 'new description',
'confidential' => true,
'dueDate' => Date.tomorrow.strftime('%Y-%m-%d')
'dueDate' => Date.tomorrow.strftime('%Y-%m-%d'),
'type' => 'ISSUE'
}
end
......@@ -37,7 +38,7 @@ RSpec.describe 'Create an issue' do
project.add_developer(current_user)
end
it 'updates the issue' do
it 'creates the issue' do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
......
......@@ -14,7 +14,8 @@ RSpec.describe 'Update of an existing issue' do
'title' => 'new title',
'description' => 'new description',
'confidential' => true,
'dueDate' => Date.tomorrow.strftime('%Y-%m-%d')
'dueDate' => Date.tomorrow.strftime('%Y-%m-%d'),
'type' => 'ISSUE'
}
end
......
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