Skip to content

Commit

Permalink
Guard against the blacklight configuration missing advanced search co…
Browse files Browse the repository at this point in the history
…nfigs
  • Loading branch information
cbeer committed Jun 15, 2017
1 parent ac4f028 commit 6368296
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/blacklight_advanced_search/advanced_search_builder.rb
Expand Up @@ -5,7 +5,7 @@ module AdvancedSearchBuilder
include Blacklight::SearchFields

def is_advanced_search?
(blacklight_params[:search_field] == self.blacklight_config.advanced_search[:url_key]) || blacklight_params[:f_inclusive]
(self.blacklight_config.advanced_search && blacklight_params[:search_field] == self.blacklight_config.advanced_search[:url_key]) || blacklight_params[:f_inclusive]
end

# this method should get added into the processor chain
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/advanced_search_builder_spec.rb
Expand Up @@ -23,6 +23,18 @@ def initialize(blacklight_config, blacklight_params)
BACTestClass.new blacklight_config, params
end

let(:params) { {} }

describe '#is_advanced_search?' do
context 'without the advanced search plugin configured' do
let(:blacklight_config) { Blacklight::Configuration.new }

it 'is false' do
expect(obj.is_advanced_search?).to be_falsey
end
end
end

context "with basic functionality" do
let(:solr_params) { {} }

Expand Down

0 comments on commit 6368296

Please sign in to comment.