Commit 106972a8 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'issue_338317' into 'master'

Show captcha verification on issue boards

See merge request gitlab-org/gitlab!72818
parents 92b253ab fddd98bf
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
module Mutations module Mutations
module Issues module Issues
class Create < BaseMutation class Create < BaseMutation
include Mutations::SpamProtection
include FindsProject include FindsProject
include CommonMutationArguments
graphql_name 'CreateIssue' graphql_name 'CreateIssue'
authorize :create_issue authorize :create_issue
include CommonMutationArguments
argument :project_path, GraphQL::Types::ID, argument :project_path, GraphQL::Types::ID,
required: true, required: true,
description: 'Project full path the issue is associated with.' description: 'Project full path the issue is associated with.'
...@@ -76,9 +77,7 @@ module Mutations ...@@ -76,9 +77,7 @@ module Mutations
spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) spam_params = ::Spam::SpamParams.new_from_request(request: context[:request])
issue = ::Issues::CreateService.new(project: project, current_user: current_user, params: params, spam_params: spam_params).execute issue = ::Issues::CreateService.new(project: project, current_user: current_user, params: params, spam_params: spam_params).execute
if issue.spam? check_spam_action_response!(issue)
issue.errors.add(:base, 'Spam detected.')
end
{ {
issue: issue.valid? ? issue : nil, issue: issue.valid? ? issue : nil,
......
...@@ -48,5 +48,9 @@ RSpec.describe 'Create an issue' do ...@@ -48,5 +48,9 @@ RSpec.describe 'Create an issue' do
expect(mutation_response['issue']).to include('discussionLocked' => true) expect(mutation_response['issue']).to include('discussionLocked' => true)
expect(Issue.last.work_item_type.base_type).to eq('issue') expect(Issue.last.work_item_type.base_type).to eq('issue')
end end
it_behaves_like 'has spam protection' do
let(:mutation_class) { ::Mutations::Issues::Create }
end
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