summaryrefslogtreecommitdiff
path: root/spec/graphql/mutations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-21 21:08:57 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-21 21:08:57 +0000
commita6c2be7cd20a9515b347e72d63c5b47bb9b79457 (patch)
tree568212b4debeb2a35bb1133209b98e1468d9ee85 /spec/graphql/mutations
parent74a2d57b337034cfdcd719615e4da06643b69114 (diff)
downloadgitlab-ce-a6c2be7cd20a9515b347e72d63c5b47bb9b79457.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/mutations')
-rw-r--r--spec/graphql/mutations/issues/update_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb
new file mode 100644
index 00000000000..3d671680ccf
--- /dev/null
+++ b/spec/graphql/mutations/issues/update_spec.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Mutations::Issues::Update do
+ let(:issue) { create(:issue) }
+ let(:user) { create(:user) }
+ let(:expected_attributes) do
+ {
+ title: 'new title',
+ description: 'new description',
+ confidential: true,
+ due_date: Date.tomorrow
+ }
+ end
+ let(:mutation) { described_class.new(object: nil, context: { current_user: user }) }
+ let(:mutated_issue) { subject[:issue] }
+
+ describe '#resolve' do
+ let(:mutation_params) do
+ {
+ project_path: issue.project.full_path,
+ iid: issue.iid
+ }.merge(expected_attributes)
+ end
+
+ subject { mutation.resolve(mutation_params) }
+
+ 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
+ before do
+ issue.project.add_developer(user)
+ end
+
+ it 'updates issue with correct values' do
+ subject
+
+ expect(issue.reload).to have_attributes(expected_attributes)
+ end
+
+ context 'when iid does not exist' do
+ it 'raises resource not available error' do
+ mutation_params[:iid] = 99999
+
+ expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
+ end
+ end
+ end
+ end
+end