Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the missing sort call in add_sorting_to_solr (#5905). #5920

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/search_builders/hyrax/collection_search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def with_access(access)
# This overrides the default 'relevance' sort.
def add_sorting_to_solr(solr_parameters)
return if solr_parameters[:q]
solr_parameters[:sort] ||= sort
solr_parameters[:sort] ||= "#{sort_field} asc"
end

Expand Down
14 changes: 14 additions & 0 deletions spec/search_builders/hyrax/collection_search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,18 @@
end
end
end

describe '#add_sorting_to_solr' do
let(:builder_2) { described_class.new(scope).with(blacklight_params) }
let(:blacklight_params) do
{ "sort" => "system_create_dtsi desc", "per_page" => "50", "locale" => "en" }
end
let(:solr_parameters) { {} }

before { builder_2.add_sorting_to_solr(solr_parameters) }

it 'sets the solr paramters for sorting correctly' do
expect(solr_parameters[:sort]).to eq('system_create_dtsi desc')
end
end
end