diff options
Diffstat (limited to 'spec/requests/api/graphql/mutations/notes/update/note_spec.rb')
-rw-r--r-- | spec/requests/api/graphql/mutations/notes/update/note_spec.rb | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/spec/requests/api/graphql/mutations/notes/update/note_spec.rb b/spec/requests/api/graphql/mutations/notes/update/note_spec.rb index bae5c58abff..dff8a87314b 100644 --- a/spec/requests/api/graphql/mutations/notes/update/note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/update/note_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Updating a Note' do +RSpec.describe 'Updating a Note', feature_category: :team_planning do include GraphqlHelpers let!(:note) { create(:note, note: original_body) } @@ -36,49 +36,32 @@ RSpec.describe 'Updating a Note' do it_behaves_like 'a Note mutation when the given resource id is not for a Note' - it 'updates the Note' do - post_graphql_mutation(mutation, current_user: current_user) - - expect(note.reload.note).to eq(updated_body) - end - - it 'returns the updated Note' do - post_graphql_mutation(mutation, current_user: current_user) - - expect(mutation_response['note']['body']).to eq(updated_body) - end + it_behaves_like 'a Note mutation updates a note successfully' + it_behaves_like 'a Note mutation update with errors' + it_behaves_like 'a Note mutation update only with quick actions' - context 'when there are ActiveRecord validation errors' do - let(:params) { { body: '', confidential: true } } + context 'for work item' do + let(:noteable) { create(:work_item, :issue) } + let(:note) { create(:note, noteable: noteable, project: noteable.project, note: original_body) } - it_behaves_like 'a mutation that returns errors in the response', - errors: ["Note can't be blank", 'Confidential can not be changed for existing notes'] + it_behaves_like 'a Note mutation updates a note successfully' + it_behaves_like 'a Note mutation update with errors' + it_behaves_like 'a Note mutation update only with quick actions' - it 'does not update the Note' do - post_graphql_mutation(mutation, current_user: current_user) - - expect(note.reload.note).to eq(original_body) - expect(note.confidential).to be_falsey - end - - it 'returns the original Note' do - post_graphql_mutation(mutation, current_user: current_user) - - expect(mutation_response['note']['body']).to eq(original_body) - expect(mutation_response['note']['confidential']).to be_falsey - end - end + context 'without notes widget' do + before do + stub_const('WorkItems::Type::BASE_TYPES', { issue: { name: 'NoNotesWidget', enum_value: 0 } }) + stub_const('WorkItems::Type::WIDGETS_FOR_TYPE', { issue: [::WorkItems::Widgets::Description] }) + end - context 'when body only contains quick actions' do - let(:updated_body) { '/close' } + it 'does not update the Note' do + post_graphql_mutation(mutation, current_user: current_user) - it 'returns a nil note and empty errors' do - post_graphql_mutation(mutation, current_user: current_user) + expect(note.reload.note).to eq(original_body) + end - expect(mutation_response).to include( - 'errors' => [], - 'note' => nil - ) + it_behaves_like 'a mutation that returns top-level errors', + errors: [Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR] end end end |