BigW Consortium Gitlab

Commit e4adf015 by Jacopo

Fixes 500 error on /estimate BIG_VALUE

parent 3a1843f9
......@@ -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?
......
---
title: Fixes 500 error on /estimate BIG_VALUE
merge_request: 18964
author: Jacopo Beschi @jacopo-beschi
type: fixed
......@@ -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 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment