Commit a1a8202f authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'use-date-for-upcoming-milestone-comparison' into 'master'

Use date for upcoming milestone comparison

Closes #58325

See merge request gitlab-org/gitlab-ce!25806
parents 52113862 8b9b37f6
......@@ -149,7 +149,7 @@ class Milestone < ActiveRecord::Base
def self.upcoming_ids(projects, groups)
rel = unscoped
.for_projects_and_groups(projects, groups)
.active.where('milestones.due_date > NOW()')
.active.where('milestones.due_date > CURRENT_DATE')
if Gitlab::Database.postgresql?
rel.order(:project_id, :group_id, :due_date).select('DISTINCT ON (project_id, group_id) id')
......@@ -161,7 +161,7 @@ class Milestone < ActiveRecord::Base
ON milestones.project_id <=> earlier_milestones.project_id
AND milestones.group_id <=> earlier_milestones.group_id
AND milestones.due_date > earlier_milestones.due_date
AND earlier_milestones.due_date > NOW()
AND earlier_milestones.due_date > CURRENT_DATE
AND earlier_milestones.state = 'active'
HEREDOC
......
---
title: Fix upcoming milestone when there are milestones with far-future due dates
merge_request:
author:
type: fixed
......@@ -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
......
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