summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-03-06 12:26:44 +0000
committerSean McGivern <sean@gitlab.com>2019-03-06 13:40:03 +0000
commit8a49eeed6db026b0454c2119ab18b0b09d9661ff (patch)
treee55b5e4b938f687e85c6c8739f5debe7ebd5add5
parentf100c9ba158a0ab6f4edaa1de73e107737d4a9d0 (diff)
downloadgitlab-ce-8a49eeed6db026b0454c2119ab18b0b09d9661ff.tar.gz
Add failing test for milestone with far-future date
When looking for upcoming milestones, we compare the milestone's due date to `NOW()`. However, the due date is a date and `NOW()` is a timestamp, and in Postgres, timestamps can't extend as far in the future as dates can. This test exposes the issue.
-rw-r--r--spec/models/milestone_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index 77b7042424c..717d4ae4ec0 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -379,6 +379,21 @@ describe Milestone do
expect(milestone_ids).to be_empty
end
end
+
+ context 'when there is a milestone with a date after 294276 AD', :postgresql do
+ before do
+ past_milestone_project_1.update!(due_date: Date.new(294277, 1, 1))
+ end
+
+ it 'returns the next upcoming open milestone ID for each project and group' do
+ expect(milestone_ids).to contain_exactly(
+ current_milestone_project_1.id,
+ current_milestone_project_2.id,
+ current_milestone_group_1.id,
+ current_milestone_group_2.id
+ )
+ end
+ end
end
describe '#to_reference' do