diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-03 00:10:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-03 00:10:04 +0300 |
commit | 5fd6c937012b886c748e74b636c6188eae2645e2 (patch) | |
tree | 6b3c5a356c9e534b0e148147bb56209a9fba033b /spec/graphql | |
parent | 0a22eaad01e62088ced6ed8d5111624be7decff0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/mutations/issues/set_assignees_spec.rb | 9 | ||||
-rw-r--r-- | spec/graphql/mutations/merge_requests/set_assignees_spec.rb | 103 |
2 files changed, 11 insertions, 101 deletions
diff --git a/spec/graphql/mutations/issues/set_assignees_spec.rb b/spec/graphql/mutations/issues/set_assignees_spec.rb new file mode 100644 index 00000000000..77ba511b715 --- /dev/null +++ b/spec/graphql/mutations/issues/set_assignees_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Issues::SetAssignees do + it_behaves_like 'an assignable resource' do + let_it_be(:resource, reload: true) { create(:issue) } + end +end diff --git a/spec/graphql/mutations/merge_requests/set_assignees_spec.rb b/spec/graphql/mutations/merge_requests/set_assignees_spec.rb index 0e7abb849c4..4ac40fc09c6 100644 --- a/spec/graphql/mutations/merge_requests/set_assignees_spec.rb +++ b/spec/graphql/mutations/merge_requests/set_assignees_spec.rb @@ -3,106 +3,7 @@ require 'spec_helper' RSpec.describe Mutations::MergeRequests::SetAssignees do - let(:merge_request) { create(:merge_request) } - let(:user) { create(:user) } - - subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } - - describe '#resolve' do - let(:assignee) { create(:user) } - let(:assignee2) { create(:user) } - let(:assignee_usernames) { [assignee.username] } - let(:mutated_merge_request) { subject[:merge_request] } - - subject { mutation.resolve(project_path: merge_request.project.full_path, iid: merge_request.iid, assignee_usernames: assignee_usernames) } - - before do - merge_request.project.add_developer(assignee) - merge_request.project.add_developer(assignee2) - end - - it 'raises an error if the resource is not accessible to the user' do - expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) - end - - context 'when the user can update the merge request' do - before do - merge_request.project.add_developer(user) - end - - it 'replaces the assignee' do - merge_request.assignees = [assignee2] - merge_request.save! - - expect(mutated_merge_request).to eq(merge_request) - expect(mutated_merge_request.assignees).to contain_exactly(assignee) - expect(subject[:errors]).to be_empty - end - - it 'returns errors merge request could not be updated' do - # Make the merge request invalid - merge_request.allow_broken = true - merge_request.update!(source_project: nil) - - expect(subject[:errors]).not_to be_empty - end - - context 'when passing an empty assignee list' do - let(:assignee_usernames) { [] } - - before do - merge_request.assignees = [assignee] - merge_request.save! - end - - it 'removes all assignees' do - expect(mutated_merge_request).to eq(merge_request) - expect(mutated_merge_request.assignees).to eq([]) - expect(subject[:errors]).to be_empty - end - end - - context 'when passing "append" as true' do - subject { mutation.resolve(project_path: merge_request.project.full_path, iid: merge_request.iid, assignee_usernames: assignee_usernames, operation_mode: Types::MutationOperationModeEnum.enum[:append]) } - - before do - merge_request.assignees = [assignee2] - merge_request.save! - - # In CE, APPEND is a NOOP as you can't have multiple assignees - # We test multiple assignment in EE specs - stub_licensed_features(multiple_merge_request_assignees: false) - end - - it 'is a NO-OP in FOSS' do - expect(mutated_merge_request).to eq(merge_request) - expect(mutated_merge_request.assignees).to contain_exactly(assignee2) - expect(subject[:errors]).to be_empty - end - end - - context 'when passing "remove" as true' do - before do - merge_request.assignees = [assignee] - merge_request.save! - end - - it 'removes named assignee' do - mutated_merge_request = mutation.resolve(project_path: merge_request.project.full_path, iid: merge_request.iid, assignee_usernames: assignee_usernames, operation_mode: Types::MutationOperationModeEnum.enum[:remove])[:merge_request] - - expect(mutated_merge_request).to eq(merge_request) - expect(mutated_merge_request.assignees).to eq([]) - expect(subject[:errors]).to be_empty - end - - it 'does not remove unnamed assignee' do - mutated_merge_request = mutation.resolve(project_path: merge_request.project.full_path, iid: merge_request.iid, assignee_usernames: [assignee2.username], operation_mode: Types::MutationOperationModeEnum.enum[:remove])[:merge_request] - - expect(mutated_merge_request).to eq(merge_request) - expect(mutated_merge_request.assignees).to contain_exactly(assignee) - expect(subject[:errors]).to be_empty - end - end - end + it_behaves_like 'an assignable resource' do + let_it_be(:resource, reload: true) { create(:merge_request) } end end |