Commit 073bd93d authored by John Hope's avatar John Hope Committed by Bob Van Landuyt

Add locked as an argument to updateIssue

parent 3089e201
...@@ -25,6 +25,12 @@ module Mutations ...@@ -25,6 +25,12 @@ module Mutations
required: false, required: false,
description: copy_field_description(Types::IssueType, :confidential) description: copy_field_description(Types::IssueType, :confidential)
argument :locked,
GraphQL::BOOLEAN_TYPE,
as: :discussion_locked,
required: false,
description: copy_field_description(Types::IssueType, :discussion_locked)
def resolve(project_path:, iid:, **args) def resolve(project_path:, iid:, **args)
issue = authorized_find!(project_path: project_path, iid: iid) issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project project = issue.project
......
---
title: Add locked as an argument to updateIssue
merge_request: 37105
author:
type: added
...@@ -14122,6 +14122,11 @@ input UpdateIssueInput { ...@@ -14122,6 +14122,11 @@ input UpdateIssueInput {
""" """
iid: String! iid: String!
"""
Indicates discussion is locked on the issue
"""
locked: Boolean
""" """
The project the issue to mutate is in The project the issue to mutate is in
""" """
......
...@@ -41716,6 +41716,16 @@ ...@@ -41716,6 +41716,16 @@
}, },
"defaultValue": null "defaultValue": null
}, },
{
"name": "locked",
"description": "Indicates discussion is locked on the issue",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{ {
"name": "healthStatus", "name": "healthStatus",
"description": "The desired health status", "description": "The desired health status",
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Mutations::Issues::Update do RSpec.describe Mutations::Issues::Update do
let(:issue) { create(:issue) } let_it_be(:issue) { create(:issue) }
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:expected_attributes) do let(:expected_attributes) do
{ {
title: 'new title', title: 'new title',
description: 'new description', description: 'new description',
confidential: true, confidential: true,
due_date: Date.tomorrow due_date: Date.tomorrow,
discussion_locked: true
} }
end end
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
...@@ -28,8 +29,10 @@ RSpec.describe Mutations::Issues::Update do ...@@ -28,8 +29,10 @@ RSpec.describe Mutations::Issues::Update do
subject { mutation.resolve(mutation_params) } subject { mutation.resolve(mutation_params) }
it 'raises an error if the resource is not accessible to the user' do context 'when the user cannot access the issue' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end end
context 'when the user can update the issue' do context 'when the user can update the issue' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Update of an existing issue' do
include GraphqlHelpers
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project) }
let(:input) do
{
project_path: project.full_path,
iid: issue.iid.to_s,
locked: true
}
end
let(:mutation) { graphql_mutation(:update_issue, input) }
let(:mutation_response) { graphql_mutation_response(:update_issue) }
context 'the user is not allowed to update issue' do
it_behaves_like 'a mutation that returns top-level errors',
errors: ['The resource that you are attempting to access does not exist or you don\'t have permission to perform this action']
end
context 'when user has permissions to update issue' do
before do
project.add_developer(current_user)
end
it 'updates the issue' do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
expect(mutation_response['issue']).to include(
'discussionLocked' => true
)
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