diff options
author | Rémy Coutable <remy@rymai.me> | 2018-05-17 17:23:32 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-05-17 17:23:32 +0000 |
commit | 4609a1268de9f15c02899c906cbb9ce27c495ab3 (patch) | |
tree | 69585303b6073bdb4ba07c721c219ab31682c39d | |
parent | 7f7f8741847175537d534d2e1b39bd70a791a879 (diff) | |
parent | e4adf0150b58d0b7f8437cbb9a3cb3ac8aa31bec (diff) | |
download | gitlab-ce-4609a1268de9f15c02899c906cbb9ce27c495ab3.tar.gz |
Merge branch '46193-fix-big-estimate' into 'master'
Resolve "Estimating a large amount results in a server error 500"
Closes #46193
See merge request gitlab-org/gitlab-ce!18964
-rw-r--r-- | app/models/concerns/time_trackable.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/46193-fix-big-estimate.yml | 5 | ||||
-rw-r--r-- | spec/models/concerns/issuable_spec.rb | 13 |
3 files changed, 22 insertions, 0 deletions
diff --git a/app/models/concerns/time_trackable.rb b/app/models/concerns/time_trackable.rb index 73fc5048dcf..1caf47072bc 100644 --- a/app/models/concerns/time_trackable.rb +++ b/app/models/concerns/time_trackable.rb @@ -53,6 +53,10 @@ module TimeTrackable Gitlab::TimeTrackingFormatter.output(time_estimate) end + def time_estimate=(val) + val.is_a?(Integer) ? super([val, Gitlab::Database::MAX_INT_VALUE].min) : super(val) + end + private def touchable? diff --git a/changelogs/unreleased/46193-fix-big-estimate.yml b/changelogs/unreleased/46193-fix-big-estimate.yml new file mode 100644 index 00000000000..d0da0c10033 --- /dev/null +++ b/changelogs/unreleased/46193-fix-big-estimate.yml @@ -0,0 +1,5 @@ +--- +title: Fixes 500 error on /estimate BIG_VALUE +merge_request: 18964 +author: Jacopo Beschi @jacopo-beschi +type: fixed diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 3d3092b8ac9..bd6bf5b0712 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -266,6 +266,19 @@ describe Issuable do end end + describe '#time_estimate=' do + it 'coerces the value below Gitlab::Database::MAX_INT_VALUE' do + expect { issue.time_estimate = 100 }.to change { issue.time_estimate }.to(100) + expect { issue.time_estimate = Gitlab::Database::MAX_INT_VALUE + 100 }.to change { issue.time_estimate }.to(Gitlab::Database::MAX_INT_VALUE) + end + + it 'skips coercion for not Integer values' do + expect { issue.time_estimate = nil }.to change { issue.time_estimate }.to(nil) + expect { issue.time_estimate = 'invalid time' }.not_to raise_error(StandardError) + expect { issue.time_estimate = 22.33 }.not_to raise_error(StandardError) + end + end + describe '#to_hook_data' do let(:builder) { double } |