Commit f0900ae8 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '230827-fix-epics-filter' into 'master'

Fix filtering epics when sorting by dates

See merge request gitlab-org/gitlab!42827
parents aff15d1e c96e1556
---
title: Fix filtering epics when sorting by dates
merge_request: 42827
author:
type: fixed
......@@ -154,6 +154,8 @@ module EE
end
class_methods do
extend ::Gitlab::Utils::Override
# We support internal references (&epic_id) and cross-references (group.full_path&epic_id)
#
# Escaped versions with `&` will be extracted too
......@@ -209,6 +211,18 @@ module EE
end
end
override :simple_sorts
def simple_sorts
super.merge(
{
'start_date_asc' => -> { order_start_date_asc.with_order_id_desc },
'start_date_desc' => -> { order_start_date_desc.with_order_id_desc },
'end_date_asc' => -> { order_end_date_asc.with_order_id_desc },
'end_date_desc' => -> { order_end_date_desc.with_order_id_desc }
}
)
end
def parent_class
::Group
end
......
......@@ -7,7 +7,7 @@ RSpec.describe EpicsFinder do
let_it_be(:search_user) { create(:user) }
let_it_be(:group) { create(:group, :private) }
let_it_be(:another_group) { create(:group) }
let_it_be(:epic1) { create(:epic, :opened, group: group, title: 'This is awesome epic', created_at: 1.week.ago) }
let_it_be(:epic1) { create(:epic, :opened, group: group, title: 'This is awesome epic', created_at: 1.week.ago, end_date: 10.days.ago) }
let_it_be(:epic2) { create(:epic, :opened, group: group, created_at: 4.days.ago, author: user, start_date: 2.days.ago, end_date: 3.days.from_now) }
let_it_be(:epic3) { create(:epic, :closed, group: group, description: 'not so awesome', start_date: 5.days.ago, end_date: 3.days.ago) }
let_it_be(:epic4) { create(:epic, :closed, group: another_group) }
......@@ -471,6 +471,11 @@ RSpec.describe EpicsFinder do
expect(filtered_epics).to contain_exactly(labeled_epic)
end
it 'filters correctly by short expressions when sorting by due date' do
expect(epics(attempt_group_search_optimizations: true, search: 'aw', sort: 'end_date_desc'))
.to eq([epic3, epic1])
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