diff options
Diffstat (limited to 'spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb b/spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb index cfa12171b7e..022e2308517 100644 --- a/spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb +++ b/spec/support/shared_examples/graphql/mutations/set_assignees_shared_examples.rb @@ -10,22 +10,40 @@ RSpec.shared_examples 'an assignable resource' do describe '#resolve' do let_it_be(:assignee) { create(:user) } let_it_be(:assignee2) { create(:user) } + let(:assignee_usernames) { [assignee.username] } let(:mutated_resource) { subject[resource.class.name.underscore.to_sym] } + let(:mode) { described_class.arguments['operationMode'].default_value } - subject { mutation.resolve(project_path: resource.project.full_path, iid: resource.iid, assignee_usernames: assignee_usernames) } - - before do - resource.project.add_developer(assignee) - resource.project.add_developer(assignee2) + subject do + mutation.resolve(project_path: resource.project.full_path, + iid: resource.iid, + operation_mode: mode, + assignee_usernames: assignee_usernames) 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 + it 'does not change assignees if the resource is not accessible to the assignees' do + resource.project.add_developer(user) + + expect { subject }.not_to change { resource.reload.assignee_ids } + end + + it 'returns an operational error if the resource is not accessible to the assignees' do + resource.project.add_developer(user) + + result = subject + + expect(result[:errors]).to include a_string_matching(/Cannot assign/) + end + context 'when the user can update the resource' do before do + resource.project.add_developer(assignee) + resource.project.add_developer(assignee2) resource.project.add_developer(user) end |