Skip to content

Commit

Permalink
Backport cb4b259 to deprecate behavior removed in 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 7, 2018
1 parent 15954ce commit fe0487e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/controllers/concerns/blacklight/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ def fetch_many(ids, user_params, extra_controller_params)
query = search_builder.
with(user_params).
where(blacklight_config.document_model.unique_key => ids).
merge(extra_controller_params).
merge(fl: '*')
merge(blacklight_config.fetch_many_document_params || deprecated_fetch_many_document_params).
merge(extra_controller_params)

solr_response = repository.search(query)

[solr_response, solr_response.documents]
Expand All @@ -152,4 +153,9 @@ def fetch_one(id, extra_controller_params)
solr_response = repository.find id, extra_controller_params
[solr_response, solr_response.documents.first]
end

def deprecated_fetch_many_document_params
Deprecation.warn(self, 'You should configure blacklight_config.fetch_many_document_params; defaulting to { fl: "*" }, but this will be removed in Blacklight 7')
{ fl: '*' }
end
end
1 change: 1 addition & 0 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def default_values
#rows: 1
},
document_pagination_params: {},
fetch_many_document_params: nil,
##
# == Response models
## Class for sending and receiving requests from a search index
Expand Down
18 changes: 18 additions & 0 deletions spec/controllers/blacklight/search_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,24 @@ def params
end
end

describe 'Get multiple documents By Id', integration: true do
let(:doc_id) { '2007020969' }
let(:bad_id) { 'redrum' }
let(:response) { subject.fetch([doc_id]).first }

before do
blacklight_config.fetch_many_document_params = { fl: 'id,format' }
end

it 'has the expected value in the id field' do
expect(response.documents.first.id).to eq doc_id
end

it 'returns all the requested fields' do
expect(response.documents.first['format']).to eq ['Book']
end
end

# SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
describe "Searches should return spelling suggestions", :integration => true do
it 'search results for just-poor-enough-query term should have (multiple) spelling suggestions' do
Expand Down

0 comments on commit fe0487e

Please sign in to comment.