Handle legacy sort order values
The sort orders used to be id_asc / id_desc, and are now created_asc / created_desc. Users can still have cookies containing the old sort orders, or bookmarks to links specifying them, so convert these to the new versions quietly.
This commit is contained in:
parent
717366d28d
commit
d3acded4bc
2 changed files with 29 additions and 0 deletions
|
@ -66,6 +66,11 @@ module IssuableCollections
|
|||
key = 'issuable_sort'
|
||||
|
||||
cookies[key] = params[:sort] if params[:sort].present?
|
||||
|
||||
# id_desc and id_asc are old values for these two.
|
||||
cookies[key] = sort_value_recently_created if cookies[key] == 'id_desc'
|
||||
cookies[key] = sort_value_oldest_created if cookies[key] == 'id_asc'
|
||||
|
||||
params[:sort] = cookies[key]
|
||||
end
|
||||
|
||||
|
|
|
@ -149,6 +149,30 @@ describe 'Projects > Issuables > Default sort order', feature: true do
|
|||
expect(last_issue).to include(first_created_issuable.title)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the sort in the URL is id_desc' do
|
||||
let(:issuable_type) { :issue }
|
||||
|
||||
before { visit_issues(project, sort: 'id_desc') }
|
||||
|
||||
it 'shows the sort order as last created' do
|
||||
expect(find('.issues-other-filters')).to have_content('Last created')
|
||||
expect(first_issue).to include(last_created_issuable.title)
|
||||
expect(last_issue).to include(first_created_issuable.title)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the sort in the URL is id_asc' do
|
||||
let(:issuable_type) { :issue }
|
||||
|
||||
before { visit_issues(project, sort: 'id_asc') }
|
||||
|
||||
it 'shows the sort order as oldest created' do
|
||||
expect(find('.issues-other-filters')).to have_content('Oldest created')
|
||||
expect(first_issue).to include(first_created_issuable.title)
|
||||
expect(last_issue).to include(last_created_issuable.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def selected_sort_order
|
||||
|
|
Loading…
Reference in a new issue