summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-08-18 23:01:03 +0000
committerRuben Davila <rdavila84@gmail.com>2016-08-18 18:51:11 -0500
commit25fb93cebbbfadc1714abfb470fe0a3cf4b44bfc (patch)
tree0996a3691f73af8413297aabd33340612021fcff
parent2e66559e382ded6608e40ed522a6d82a9e851956 (diff)
downloadgitlab-ce-25fb93cebbbfadc1714abfb470fe0a3cf4b44bfc.tar.gz
Merge branch '21028-missing-default-sort-for-users-with-an-existing-cookie' into 'master'
Handle legacy sort order values Convert the legacy sort order values id_asc / id_desc into the ones we use now, created_at / created_desc, to stop the dropdown being blank. Closes #21028. See merge request !5880
-rw-r--r--app/controllers/concerns/issuable_collections.rb5
-rw-r--r--spec/features/issuables/default_sort_order_spec.rb24
2 files changed, 29 insertions, 0 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb
index c802922e0af..b5e79099e39 100644
--- a/app/controllers/concerns/issuable_collections.rb
+++ b/app/controllers/concerns/issuable_collections.rb
@@ -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
diff --git a/spec/features/issuables/default_sort_order_spec.rb b/spec/features/issuables/default_sort_order_spec.rb
index 9114f751b55..9a2b879e789 100644
--- a/spec/features/issuables/default_sort_order_spec.rb
+++ b/spec/features/issuables/default_sort_order_spec.rb
@@ -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