Commit e02439db authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '336669-fix-iterations-ordering' into 'master'

Make iterations finder ordering deterministic

See merge request gitlab-org/gitlab!66649
parents 69e8a347 755205f6
......@@ -82,8 +82,7 @@ class IterationsFinder
# rubocop: disable CodeReuse/ActiveRecord
def order(items)
order_statement = Gitlab::Database.nulls_last_order('due_date', 'ASC')
items.reorder(order_statement).order(:title)
items.reorder(:due_date).order(:title, { id: :asc })
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -66,8 +66,8 @@ RSpec.describe IterationsFinder do
expect(subject).to contain_exactly(root_closed_iteration, root_group_iteration, closed_iteration, started_group_iteration, upcoming_group_iteration)
end
it 'orders iterations by due date' do
expect(subject.to_a).to eq([closed_iteration, root_closed_iteration, started_group_iteration, root_group_iteration, upcoming_group_iteration])
it 'orders iterations by due date and title' do
expect(subject.to_a).to eq([closed_iteration, root_closed_iteration, started_group_iteration, root_group_iteration, upcoming_group_iteration].sort_by { |a| [a.due_date, a.title, a.id] })
end
end
......
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