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

I3048 backport nil json param #3074

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
3 changes: 2 additions & 1 deletion lib/blacklight/solr/search_builder_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ def add_additional_filters(solr_parameters, additional_filters = nil)
end

def add_search_field_with_json_query_parameters(solr_parameters)
bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
return unless search_state.query_param

bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
solr_parameters.append_boolean_query(:must, bool_query)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/models/blacklight/solr/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,14 @@
it 'includes addtional clause parameters for the field' do
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include another: :parameter
end

context 'with an empty search' do
let(:subject_search_params) { { commit: "search", search_field: "subject", action: "index", controller: "catalog", rows: "10", q: nil } }

it 'does not add nil query value clauses to json query' do
expect(subject).not_to have_key :json
end
end
end

describe "overriding of qt parameter" do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

Capybara.register_driver :headless_chrome do |app|
Capybara::Selenium::Driver.load_selenium
capabilities = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.args << '--headless'
opts.args << '--disable-gpu'
opts.args << '--no-sandbox'
opts.args << '--window-size=1280,1696'
end
Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: capabilities)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

# Requires supporting ruby files with custom matchers and macros, etc,
Expand Down
Loading