Commit a1245430 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '36319-follow-up' into 'master'

Add locked as an argument to updateIssue

See merge request gitlab-org/gitlab!37105
parents 124cb3d9 073bd93d
......@@ -25,6 +25,12 @@ module Mutations
required: false,
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)
issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project
......
---
title: Add locked as an argument to updateIssue
merge_request: 37105
author:
type: added
......@@ -14122,6 +14122,11 @@ input UpdateIssueInput {
"""
iid: String!
"""
Indicates discussion is locked on the issue
"""
locked: Boolean
"""
The project the issue to mutate is in
"""
......
......@@ -41716,6 +41716,16 @@
},
"defaultValue": null
},
{
"name": "locked",
"description": "Indicates discussion is locked on the issue",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "healthStatus",
"description": "The desired health status",
......@@ -3,14 +3,15 @@
require 'spec_helper'
RSpec.describe Mutations::Issues::Update do
let(:issue) { create(:issue) }
let(:user) { create(:user) }
let_it_be(:issue) { create(:issue) }
let_it_be(:user) { create(:user) }
let(:expected_attributes) do
{
title: 'new title',
description: 'new description',
confidential: true,
due_date: Date.tomorrow
due_date: Date.tomorrow,
discussion_locked: true
}
end
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
......@@ -28,8 +29,10 @@ RSpec.describe Mutations::Issues::Update do
subject { mutation.resolve(mutation_params) }
it 'raises an error if the resource is not accessible to the user' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
context 'when the user cannot access the issue' do
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
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