diff options
Diffstat (limited to 'spec/graphql/mutations/issues')
6 files changed, 19 insertions, 19 deletions
diff --git a/spec/graphql/mutations/issues/set_assignees_spec.rb b/spec/graphql/mutations/issues/set_assignees_spec.rb index 77ba511b715..9a27c5acdac 100644 --- a/spec/graphql/mutations/issues/set_assignees_spec.rb +++ b/spec/graphql/mutations/issues/set_assignees_spec.rb @@ -3,6 +3,20 @@ require 'spec_helper' RSpec.describe Mutations::Issues::SetAssignees do + context 'when the user does not have permissions' do + let_it_be(:issue) { create(:issue) } + let_it_be(:user) { create(:user) } + let_it_be(:assignee) { create(:user) } + + subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } + + describe '#resolve' do + subject { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, assignee_usernames: [assignee.username]) } + + it_behaves_like 'permission level for issue mutation is correctly verified' + end + end + it_behaves_like 'an assignable resource' do let_it_be(:resource, reload: true) { create(:issue) } end diff --git a/spec/graphql/mutations/issues/set_confidential_spec.rb b/spec/graphql/mutations/issues/set_confidential_spec.rb index 0b2fc0ecb93..c3269e5c0c0 100644 --- a/spec/graphql/mutations/issues/set_confidential_spec.rb +++ b/spec/graphql/mutations/issues/set_confidential_spec.rb @@ -17,9 +17,7 @@ RSpec.describe Mutations::Issues::SetConfidential do subject { mutation.resolve(project_path: project.full_path, iid: issue.iid, confidential: confidential) } - 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_behaves_like 'permission level for issue mutation is correctly verified' context 'when the user can update the issue' do before do diff --git a/spec/graphql/mutations/issues/set_due_date_spec.rb b/spec/graphql/mutations/issues/set_due_date_spec.rb index a638971d966..9f8d0d6c405 100644 --- a/spec/graphql/mutations/issues/set_due_date_spec.rb +++ b/spec/graphql/mutations/issues/set_due_date_spec.rb @@ -16,9 +16,7 @@ RSpec.describe Mutations::Issues::SetDueDate do subject { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, due_date: due_date) } - 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_behaves_like 'permission level for issue mutation is correctly verified' context 'when the user can update the issue' do before do diff --git a/spec/graphql/mutations/issues/set_locked_spec.rb b/spec/graphql/mutations/issues/set_locked_spec.rb index 10438226c17..1a0af0c6c63 100644 --- a/spec/graphql/mutations/issues/set_locked_spec.rb +++ b/spec/graphql/mutations/issues/set_locked_spec.rb @@ -15,9 +15,7 @@ RSpec.describe Mutations::Issues::SetLocked do subject { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, locked: locked) } - 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_behaves_like 'permission level for issue mutation is correctly verified' context 'when the user can update the issue' do let(:mutated_issue) { subject[:issue] } diff --git a/spec/graphql/mutations/issues/set_severity_spec.rb b/spec/graphql/mutations/issues/set_severity_spec.rb index ed73d3b777e..7698118ae3e 100644 --- a/spec/graphql/mutations/issues/set_severity_spec.rb +++ b/spec/graphql/mutations/issues/set_severity_spec.rb @@ -15,11 +15,7 @@ RSpec.describe Mutations::Issues::SetSeverity do subject(:resolve) { mutation.resolve(project_path: issue.project.full_path, iid: issue.iid, severity: severity) } - context 'when the user cannot update the issue' do - it 'raises an error' do - expect { resolve }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) - end - end + it_behaves_like 'permission level for issue mutation is correctly verified' context 'when the user can update the issue' do before do diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb index f9f4bdeb6fa..ce1eb874bcf 100644 --- a/spec/graphql/mutations/issues/update_spec.rb +++ b/spec/graphql/mutations/issues/update_spec.rb @@ -35,11 +35,7 @@ RSpec.describe Mutations::Issues::Update do subject { mutation.resolve(mutation_params) } - context 'when the user cannot access the issue' do - it 'raises an error' do - expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) - end - end + it_behaves_like 'permission level for issue mutation is correctly verified' context 'when the user can update the issue' do before do |