diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-16 03:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-16 03:09:17 +0300 |
commit | b0da29fca999ca9e042d99b556a7a69b7812dcfd (patch) | |
tree | 2f0b19ee8fee20dda14b4fe8c029a3131d95a7eb /spec/graphql | |
parent | 651917dbac09fc4fe9217c08d68420019dff59fb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/mutations/alert_management/update_alert_status_spec.rb | 2 | ||||
-rw-r--r-- | spec/graphql/mutations/issues/set_locked_spec.rb | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/spec/graphql/mutations/alert_management/update_alert_status_spec.rb b/spec/graphql/mutations/alert_management/update_alert_status_spec.rb index 68513c02040..a224b564de9 100644 --- a/spec/graphql/mutations/alert_management/update_alert_status_spec.rb +++ b/spec/graphql/mutations/alert_management/update_alert_status_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Mutations::AlertManagement::UpdateAlertStatus do allow(alert).to receive(:save).and_return(false) allow(alert).to receive(:errors).and_return( - double(full_messages: %w(foo bar)) + double(full_messages: %w(foo bar), :[] => nil) ) expect(resolve).to eq( alert: alert, diff --git a/spec/graphql/mutations/issues/set_locked_spec.rb b/spec/graphql/mutations/issues/set_locked_spec.rb new file mode 100644 index 00000000000..10438226c17 --- /dev/null +++ b/spec/graphql/mutations/issues/set_locked_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Issues::SetLocked do + let_it_be(:issue) { create(:issue) } + let_it_be(:user) { create(:user) } + + subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } + + specify { expect(described_class).to require_graphql_authorizations(:update_issue) } + + describe '#resolve' do + let(:locked) { true } + + 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 + + context 'when the user can update the issue' do + let(:mutated_issue) { subject[:issue] } + + before do + issue.project.add_developer(user) + end + + it 'returns the issue as discussion locked' do + expect(mutated_issue).to eq(issue) + expect(mutated_issue).to be_discussion_locked + expect(subject[:errors]).to be_empty + end + + context 'when passing locked as false' do + let(:locked) { false } + + it 'unlocks the discussion' do + issue.update!(discussion_locked: true) + + expect(mutated_issue).not_to be_discussion_locked + end + end + end + end +end |