Commit c94eab1b authored by Robert Speicher's avatar Robert Speicher

Merge branch '36312-issue-update-milestone' into 'master'

Add milestone_id to issue update graphQL mutation

See merge request gitlab-org/gitlab!38684
parents 1e9a4da6 cf99162d
......@@ -41,6 +41,11 @@ module Mutations
required: false,
description: 'The IDs of labels to be removed from the issue.'
argument :milestone_id,
GraphQL::ID_TYPE,
required: false,
description: 'The ID of the milestone to be assigned, milestone will be removed if set to null.'
def resolve(project_path:, iid:, **args)
issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project
......
---
title: Add milestone_id param to issue update graphQL mutation
merge_request: 38684
author:
type: added
......@@ -15077,6 +15077,11 @@ input UpdateIssueInput {
"""
locked: Boolean
"""
The ID of the milestone to be assigned, milestone will be removed if set to null.
"""
milestoneId: ID
"""
The project the issue to mutate is in
"""
......
......@@ -44467,6 +44467,16 @@
},
"defaultValue": null
},
{
"name": "milestoneId",
"description": "The ID of the milestone to be assigned, milestone will be removed if set to null.",
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
{
"name": "healthStatus",
"description": "The desired health status",
......@@ -7,6 +7,7 @@ RSpec.describe Mutations::Issues::Update do
let_it_be(:user) { create(:user) }
let_it_be(:project_label) { create(:label, project: project) }
let_it_be(:issue) { create(:issue, project: project, labels: [project_label]) }
let_it_be(:milestone) { create(:milestone, project: project) }
let(:expected_attributes) do
{
......@@ -14,7 +15,8 @@ RSpec.describe Mutations::Issues::Update do
description: 'new description',
confidential: true,
due_date: Date.tomorrow,
discussion_locked: true
discussion_locked: true,
milestone_id: milestone.id
}
end
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
......@@ -57,6 +59,16 @@ RSpec.describe Mutations::Issues::Update do
end
end
context 'when setting milestone to nil' do
let(:expected_attributes) { { milestone_id: nil } }
it 'changes the milestone corrrectly' do
issue.update_column(:milestone_id, milestone.id)
expect { subject }.to change { issue.reload.milestone }.from(milestone).to(nil)
end
end
context 'when changing labels' do
let_it_be(:label_1) { create(:label, project: project) }
let_it_be(:label_2) { create(:label, project: project) }
......
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