Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
collections: add rdcp sort test re: user select
Browse files Browse the repository at this point in the history
- Only apply RDCP sorting if a user has not already selected a sort
  option in the UI
- Adds a test for a user selected option when browsing RDCP collections
  • Loading branch information
mcritchlow committed Jun 20, 2019
1 parent ec5f8bd commit 7a26832
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 8 additions & 5 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,15 @@ def collection_search
@current_unit_code = params[:id]
end

# sort by title
params[:sort] = 'title_ssi asc' unless params[:sort]
# apply default sorting rules if user has not selected one
unless params[:sort]
# sort by title
params[:sort] = 'title_ssi asc'
# RDCP prefers their collections sorted by most recently created first
# Therefore, we're sorting by modified date rather than title
params[:sort] = 'system_modified_dtsi desc, title_ssi asc' if params[:id].eql? 'rdcp'
end

# RDCP prefers their collections sorted by most recently created first
# Therefore, we're sorting by modified date rather than title
params[:sort] = 'system_modified_dtsi desc, title_ssi asc' if params[:id].eql? 'rdcp'
(@response, @document_list) = get_search_results params, params

# update session
Expand Down
9 changes: 8 additions & 1 deletion spec/features/collections_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@
@oldest_collection.delete
@newest_collection.delete
end
it 'should sort by most recent collection, descending to oldest' do
it 'should sort by most recent collection by default, descending to oldest' do
visit dams_unit_collections_path('rdcp')
old_collection_sort_order = page.body.index('A Old Collection')
new_collection_sort_order = page.body.index('The New Collection')
expect(old_collection_sort_order).to be > new_collection_sort_order
end

it 'should still allow user selected sort options' do
visit dams_unit_collections_path('rdcp', { sort: 'title_ssi asc' })
old_collection_sort_order = page.body.index('A Old Collection')
new_collection_sort_order = page.body.index('The New Collection')
expect(old_collection_sort_order).to be < new_collection_sort_order
end
end

describe 'DLDP browse by collection page' do
Expand Down

0 comments on commit 7a26832

Please sign in to comment.