spec/models/blacklight/solr/search_builder_spec.rb in blacklight-7.33.1 vs spec/models/blacklight/solr/search_builder_spec.rb in blacklight-7.34.0

- old
+ new

@@ -189,10 +189,18 @@ expect(subject[:phrase_filters]).to be_blank expect(subject[:fq]).to be_blank end end + describe "for a missing string search" do + let(:user_params) { { q: nil } } + + it "does not populate the q parameter in solr parameters" do + expect(subject).not_to have_key :q + end + end + describe "for an empty string search" do let(:user_params) { { q: "" } } it "returns empty string q in solr parameters" do expect(subject[:q]).to eq "" @@ -395,9 +403,17 @@ expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include query: 'wome' end 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 let(:user_params) do