Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/graphql/mutations/notes/create/note_spec.rb')
-rw-r--r--spec/requests/api/graphql/mutations/notes/create/note_spec.rb33
1 files changed, 30 insertions, 3 deletions
diff --git a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb
index 87c752393ea..2bc671e4ca5 100644
--- a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb
+++ b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb
@@ -8,13 +8,16 @@ RSpec.describe 'Adding a Note' do
let_it_be(:current_user) { create(:user) }
let(:noteable) { create(:merge_request, source_project: project, target_project: project) }
- let(:project) { create(:project) }
+ let(:project) { create(:project, :repository) }
let(:discussion) { nil }
+ let(:head_sha) { nil }
+ let(:body) { 'Body text' }
let(:mutation) do
variables = {
noteable_id: GitlabSchema.id_from_object(noteable).to_s,
discussion_id: (GitlabSchema.id_from_object(discussion).to_s if discussion),
- body: 'Body text',
+ merge_request_diff_head_sha: head_sha.presence,
+ body: body,
confidential: true
}
@@ -54,7 +57,7 @@ RSpec.describe 'Adding a Note' do
let(:discussion) { create(:discussion_note).to_discussion }
it_behaves_like 'a mutation that returns top-level errors',
- errors: ["The discussion does not exist or you don't have permission to perform this action"]
+ errors: ["The discussion does not exist or you don't have permission to perform this action"]
end
context 'when the user has permission to create notes on the discussion' do
@@ -75,5 +78,29 @@ RSpec.describe 'Adding a Note' do
end
end
end
+
+ context 'when body only contains quick actions' do
+ let(:head_sha) { noteable.diff_head_sha }
+ let(:body) { '/merge' }
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ # NOTE: Known issue https://gitlab.com/gitlab-org/gitlab/-/issues/346557
+ it 'returns a nil note and info about the command in errors' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ expect(mutation_response).to include(
+ 'errors' => [/Merged this merge request/],
+ 'note' => nil
+ )
+ end
+
+ it 'starts the merge process' do
+ expect { post_graphql_mutation(mutation, current_user: current_user) }
+ .to change { noteable.reload.merge_jid.present? }.from(false).to(true)
+ end
+ end
end
end