Commit 083556f8 authored by Thong Kuah's avatar Thong Kuah

Merge branch '331625-sort-epics-case-insensitive' into 'master'

When sorting epics by title, do so in a case-insensitive way

See merge request gitlab-org/gitlab!67125
parents 1cba1f00 26c06b42
......@@ -112,13 +112,8 @@ module EE
reorder(keyset_order)
end
scope :order_title_asc, -> do
reorder(title: :asc)
end
scope :order_title_desc, -> do
reorder(title: :desc)
end
scope :order_title_asc, -> { reorder(Arel::Nodes::Ascending.new(arel_table[:title].lower)) }
scope :order_title_desc, -> { reorder(Arel::Nodes::Descending.new(arel_table[:title].lower)) }
scope :order_closed_date_desc, -> { reorder(closed_at: :desc) }
......
......@@ -91,15 +91,16 @@ RSpec.describe Epic do
let_it_be(:epic1) { create(:epic, title: 'foo') }
let_it_be(:epic2) { create(:epic, title: 'bar') }
let_it_be(:epic3) { create(:epic, title: 'baz') }
let_it_be(:epic4) { create(:epic, title: 'Baz 2') }
describe '.order_title_asc' do
it 'returns epics ordered by title, ascending' do
expect(described_class.order_title_asc).to eq([epic2, epic3, epic1, confidential_epic, public_epic])
expect(described_class.order_title_asc).to eq([epic2, epic3, epic4, epic1, confidential_epic, public_epic])
end
describe '.order_title_desc' do
it 'returns epics ordered by title, decending' do
expect(described_class.order_title_desc).to eq([public_epic, confidential_epic, epic1, epic3, epic2])
expect(described_class.order_title_desc).to eq([public_epic, confidential_epic, epic1, epic4, epic3, epic2])
end
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