Commit 755205f6 authored by Alexandru Croitor's avatar Alexandru Croitor

Make iterations finder ordering deterministic

parent 7678d206
......@@ -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