Commit 26c06b42 authored by Andrew Smith's avatar Andrew Smith

When ordering epics by title, do so case-insensitively

Changelog: fixed
EE: true
parent 21607dbf
...@@ -112,13 +112,8 @@ module EE ...@@ -112,13 +112,8 @@ module EE
reorder(keyset_order) reorder(keyset_order)
end end
scope :order_title_asc, -> do scope :order_title_asc, -> { reorder(Arel::Nodes::Ascending.new(arel_table[:title].lower)) }
reorder(title: :asc) scope :order_title_desc, -> { reorder(Arel::Nodes::Descending.new(arel_table[:title].lower)) }
end
scope :order_title_desc, -> do
reorder(title: :desc)
end
scope :order_closed_date_desc, -> { reorder(closed_at: :desc) } scope :order_closed_date_desc, -> { reorder(closed_at: :desc) }
......
...@@ -91,15 +91,16 @@ RSpec.describe Epic do ...@@ -91,15 +91,16 @@ RSpec.describe Epic do
let_it_be(:epic1) { create(:epic, title: 'foo') } let_it_be(:epic1) { create(:epic, title: 'foo') }
let_it_be(:epic2) { create(:epic, title: 'bar') } let_it_be(:epic2) { create(:epic, title: 'bar') }
let_it_be(:epic3) { create(:epic, title: 'baz') } let_it_be(:epic3) { create(:epic, title: 'baz') }
let_it_be(:epic4) { create(:epic, title: 'Baz 2') }
describe '.order_title_asc' do describe '.order_title_asc' do
it 'returns epics ordered by title, ascending' 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 end
describe '.order_title_desc' do describe '.order_title_desc' do
it 'returns epics ordered by title, decending' 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 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