Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-25 21:06:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-25 21:06:04 +0300
commit801ced25ff0540b096c395f9ac8d2d9e005878e8 (patch)
tree4f3ee19fd0facc1bcda8b93881981ab3315b9658 /spec/graphql/mutations
parented9c54b56af280cc552aaac1cfa55533c900c1be (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/mutations')
-rw-r--r--spec/graphql/mutations/issues/set_due_date_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/graphql/mutations/issues/set_due_date_spec.rb b/spec/graphql/mutations/issues/set_due_date_spec.rb
new file mode 100644
index 00000000000..9a1f0925fe3
--- /dev/null
+++ b/spec/graphql/mutations/issues/set_due_date_spec.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Mutations::Issues::SetDueDate do
+ let(:issue) { create(:issue) }
+ let(:user) { create(:user) }
+ subject(:mutation) { described_class.new(object: nil, context: { current_user: user }) }
+
+ describe '#resolve' do
+ let(:due_date) { 2.days.since }
+ let(:mutated_issue) { subject[:issue] }
+ 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
+
+ context 'when the user can update the issue' do
+ before do
+ issue.project.add_developer(user)
+ end
+
+ it 'returns the issue with updated due date' do
+ expect(mutated_issue).to eq(issue)
+ expect(mutated_issue.due_date).to eq(Date.today + 2.days)
+ expect(subject[:errors]).to be_empty
+ end
+
+ context 'when passing incorrect due date value' do
+ let(:due_date) { 'test' }
+
+ it 'does not update due date' do
+ expect(mutated_issue.due_date).to eq(issue.due_date)
+ end
+ end
+ end
+ end
+end