Skip to content

Commit

Permalink
SolrRepository#find should prefer the default_document_solr_params[:q…
Browse files Browse the repository at this point in the history
…t] over document_solr_request_handler
  • Loading branch information
cbeer committed Apr 9, 2015
1 parent 719b3d5 commit b6bf4a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/blacklight/solr_repository.rb
Expand Up @@ -12,8 +12,8 @@ class SolrRepository < AbstractRepository
# @param [String] document's unique key value
# @param [Hash] additional solr query parameters
def find id, params = {}
doc_params = params.reverse_merge(qt: blacklight_config.document_solr_request_handler)
.reverse_merge(blacklight_config.default_document_solr_params)
doc_params = params.reverse_merge(blacklight_config.default_document_solr_params)
.reverse_merge(qt: blacklight_config.document_solr_request_handler)
.merge(blacklight_config.document_unique_id_param => id)

solr_response = send_and_receive blacklight_config.document_solr_path || blacklight_config.solr_path, doc_params
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/blacklight/solr_repository_spec.rb
Expand Up @@ -42,6 +42,13 @@
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc'})).and_return(mock_response)
expect(subject.find("123", {qt: 'abc'})).to be_a_kind_of Blacklight::SolrResponse
end

it "should use the :qt parameter from the default_document_solr_params" do
blacklight_config.default_document_solr_params[:qt] = 'abc'
blacklight_config.document_solr_request_handler = 'xyz'
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc'})).and_return(mock_response)
expect(subject.find("123")).to be_a_kind_of Blacklight::SolrResponse
end

it "should preserve the class of the incoming params" do
doc_params = HashWithIndifferentAccess.new
Expand Down

0 comments on commit b6bf4a3

Please sign in to comment.