Commit 0696c302 authored by Mario Celi's avatar Mario Celi

WorkItemUpdate mutation allows to update title

Mutation allows updating the title attribute
of a work item
parent 87c7c624
...@@ -18,6 +18,9 @@ module Mutations ...@@ -18,6 +18,9 @@ module Mutations
argument :state_event, Types::WorkItems::StateEventEnum, argument :state_event, Types::WorkItems::StateEventEnum,
description: 'Close or reopen a work item.', description: 'Close or reopen a work item.',
required: false required: false
argument :title, GraphQL::Types::String,
required: false,
description: copy_field_description(Types::WorkItemType, :title)
field :work_item, Types::WorkItemType, field :work_item, Types::WorkItemType,
null: true, null: true,
......
...@@ -5200,6 +5200,7 @@ Input type: `WorkItemUpdateInput` ...@@ -5200,6 +5200,7 @@ Input type: `WorkItemUpdateInput`
| <a id="mutationworkitemupdateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. | | <a id="mutationworkitemupdateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
| <a id="mutationworkitemupdateid"></a>`id` | [`WorkItemID!`](#workitemid) | Global ID of the work item. | | <a id="mutationworkitemupdateid"></a>`id` | [`WorkItemID!`](#workitemid) | Global ID of the work item. |
| <a id="mutationworkitemupdatestateevent"></a>`stateEvent` | [`WorkItemStateEvent`](#workitemstateevent) | Close or reopen a work item. | | <a id="mutationworkitemupdatestateevent"></a>`stateEvent` | [`WorkItemStateEvent`](#workitemstateevent) | Close or reopen a work item. |
| <a id="mutationworkitemupdatetitle"></a>`title` | [`String`](#string) | Title of the work item. |
#### Fields #### Fields
...@@ -10,7 +10,7 @@ RSpec.describe 'Update a work item' do ...@@ -10,7 +10,7 @@ RSpec.describe 'Update a work item' do
let_it_be(:work_item, refind: true) { create(:work_item, project: project) } let_it_be(:work_item, refind: true) { create(:work_item, project: project) }
let(:work_item_event) { 'CLOSE' } let(:work_item_event) { 'CLOSE' }
let(:input) { { 'stateEvent' => work_item_event } } let(:input) { { 'stateEvent' => work_item_event, 'title' => 'updated title' } }
let(:mutation) { graphql_mutation(:workItemUpdate, input.merge('id' => work_item.to_global_id.to_s)) } let(:mutation) { graphql_mutation(:workItemUpdate, input.merge('id' => work_item.to_global_id.to_s)) }
...@@ -26,15 +26,18 @@ RSpec.describe 'Update a work item' do ...@@ -26,15 +26,18 @@ RSpec.describe 'Update a work item' do
let(:current_user) { developer } let(:current_user) { developer }
context 'when the work item is open' do context 'when the work item is open' do
it 'closes the work item' do it 'closes and updates the work item' do
expect do expect do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
work_item.reload work_item.reload
end.to change(work_item, :state).from('opened').to('closed') end.to change(work_item, :state).from('opened').to('closed').and(
change(work_item, :title).from(work_item.title).to('updated title')
)
expect(response).to have_gitlab_http_status(:success) expect(response).to have_gitlab_http_status(:success)
expect(mutation_response['workItem']).to include( expect(mutation_response['workItem']).to include(
'state' => 'CLOSED' 'state' => 'CLOSED',
'title' => 'updated title'
) )
end end
end 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