Skip to content

Commit

Permalink
Merge pull request projectblacklight#106 from dkinzer/fix-local-param…
Browse files Browse the repository at this point in the history
…-hash-fails

Fix  local_params_hash method fails field_def is nil.
  • Loading branch information
jkeck authored Nov 6, 2019
2 parents aee4fa2 + 9ed6afd commit 4e2ba68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/blacklight_advanced_search/parsing_nesting_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def process_query(_params, config)
end

def local_param_hash(key, config)
field_def = config.search_fields[key]
field_def = config.search_fields[key] || {}

(field_def[:solr_adv_parameters] || field_def[:solr_parameters] || {}).merge(field_def[:solr_local_parameters] || {})
end
Expand Down
20 changes: 20 additions & 0 deletions spec/lib/blacklight_advanced_search/parsing_nesting_parser_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe BlacklightAdvancedSearch::ParsingNestingParser, type: :module do
let(:blacklight_config) do
Blacklight::Configuration.new do |config|
config.add_facet_field 'type'
end
end

let(:subject) { (Object.new).extend(BlacklightAdvancedSearch::ParsingNestingParser) }

describe "#local_param_hash" do

context 'with config[key] being nil' do
let(:key) { "foo" }

it "does not fail do no nil error" do
expect { subject.local_param_hash(key, blacklight_config) }.not_to raise_error
end
end
end
end

0 comments on commit 4e2ba68

Please sign in to comment.