summaryrefslogtreecommitdiff
path: root/spec/graphql/mutations/issues/update_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/graphql/mutations/issues/update_spec.rb')
-rw-r--r--spec/graphql/mutations/issues/update_spec.rb41
1 files changed, 38 insertions, 3 deletions
diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb
index bb57ad4c404..324f225f209 100644
--- a/spec/graphql/mutations/issues/update_spec.rb
+++ b/spec/graphql/mutations/issues/update_spec.rb
@@ -46,10 +46,12 @@ RSpec.describe Mutations::Issues::Update do
project.add_developer(user)
end
- it 'updates issue with correct values' do
- subject
+ context 'when all attributes except timeEstimate are provided' do
+ it 'updates issue with correct values' do
+ subject
- expect(issue.reload).to have_attributes(expected_attributes)
+ expect(issue.reload).to have_attributes(expected_attributes)
+ end
end
context 'when iid does not exist' do
@@ -162,6 +164,39 @@ RSpec.describe Mutations::Issues::Update do
expect { subject }.to change { issue.reload.issue_type }.from('issue').to('incident')
end
end
+
+ context 'when timeEstimate attribute is provided' do
+ let_it_be_with_refind(:issue) { create(:issue, project: project, time_estimate: 3600) }
+
+ let(:time_estimate) { '0' }
+ let(:expected_attributes) { { time_estimate: time_estimate } }
+
+ context 'when timeEstimate is invalid' do
+ let(:time_estimate) { '1e' }
+
+ it 'raises an argument error and changes are not applied' do
+ expect { mutation.ready?(time_estimate: time_estimate) }
+ .to raise_error(Gitlab::Graphql::Errors::ArgumentError, 'timeEstimate must be formatted correctly, for example `1h 30m`')
+ expect { subject }.not_to change { issue.reload.time_estimate }
+ end
+ end
+
+ context 'when timeEstimate is 0' do
+ let(:time_estimate) { '0' }
+
+ it 'resets the time estimate' do
+ expect { subject }.to change { issue.reload.time_estimate }.from(3600).to(0)
+ end
+ end
+
+ context 'when timeEstimate is a valid human readable time' do
+ let(:time_estimate) { '1h 30m' }
+
+ it 'updates the time estimate' do
+ expect { subject }.to change { issue.reload.time_estimate }.from(3600).to(5400)
+ end
+ end
+ end
end
end
end