2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Mutations::Issues::SetDueDate do
|
2021-06-08 01:23:25 +05:30
|
|
|
let(:issue) { create(:issue, due_date: '2021-05-01') }
|
|
|
|
|
|
|
|
let_it_be(:user) { create(:user) }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
specify { expect(described_class).to require_graphql_authorizations(:update_issue) }
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
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) }
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
it_behaves_like 'permission level for issue mutation is correctly verified'
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
context 'when the user can update the issue' do
|
|
|
|
before do
|
|
|
|
issue.project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'returns the issue with updated due date', :aggregate_failures do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(mutated_issue).to eq(issue)
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(mutated_issue.due_date).to eq(due_date.to_date)
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(subject[:errors]).to be_empty
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
context 'when due date is nil' do
|
|
|
|
let(:due_date) { nil }
|
|
|
|
|
|
|
|
it 'updates due date to be nil' do
|
|
|
|
expect(mutated_issue.due_date).to be nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
context 'when passing incorrect due date value' do
|
|
|
|
let(:due_date) { 'test' }
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'updates due date to be nil' do
|
|
|
|
expect(mutated_issue.due_date).to be nil
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|