diff options
author | Luke Duncalfe <lduncalfe@eml.cc> | 2019-07-04 15:33:14 +1200 |
---|---|---|
committer | Luke Duncalfe <lduncalfe@eml.cc> | 2019-07-10 12:13:48 +1200 |
commit | 073c8b25ea36b6b96eab05eb675e8726b1d5318e (patch) | |
tree | 5f83a17cf6e461106d8ddf8f1b84f743a09547d6 /spec/requests/api/graphql/mutations/notes/create/note_spec.rb | |
parent | 254f78f5dc36d4aef26d1ab2a924e4fa916221c6 (diff) | |
download | gitlab-ce-073c8b25ea36b6b96eab05eb675e8726b1d5318e.tar.gz |
GraphQL support for Notes created in discussions62826-graphql-note-mutations
A new `discussion_id` argument on the `createNote` mutation allows
people to create a note within that discussion.
The ability to lazy-load Discussions has been added, so
GraphQL.object_from_id can treat Discussions the same as AR objects and
batch load them.
https://gitlab.com/gitlab-org/gitlab-ce/issues/62826
https://gitlab.com/gitlab-org/gitlab-ee/issues/9489
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.rb | 23 |
1 files changed, 22 insertions, 1 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 17aed69b650..14aaa430ac9 100644 --- a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb @@ -7,10 +7,12 @@ describe 'Adding a Note' do set(:current_user) { create(:user) } let(:noteable) { create(:merge_request, source_project: project, target_project: project) } - let(:project) { create(:project, :repository) } + let(:project) { create(:project) } + let(:discussion) { nil } 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' } @@ -39,5 +41,24 @@ describe 'Adding a Note' do expect(mutation_response['note']['body']).to eq('Body text') end + + describe 'creating Notes in reply to a discussion' do + context 'when the user does not have permission to create notes on the discussion' 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"] + end + + context 'when the user has permission to create notes on the discussion' do + let(:discussion) { create(:discussion_note, project: project).to_discussion } + + it 'creates a Note in a discussion' do + post_graphql_mutation(mutation, current_user: current_user) + + expect(mutation_response['note']['discussion']['id']).to eq(discussion.to_global_id.to_s) + end + end + end end end |