diff --git a/app/services/discovery_engine/query/best_bets_boost.rb b/app/services/discovery_engine/query/best_bets_boost.rb index 639b37e..d0825d2 100644 --- a/app/services/discovery_engine/query/best_bets_boost.rb +++ b/app/services/discovery_engine/query/best_bets_boost.rb @@ -1,7 +1,7 @@ module DiscoveryEngine::Query class BestBetsBoost def initialize(query_string) - @query_string = query_string + @query_string = query_string.strip.downcase.gsub(/\s+/, " ") end def boost_specs diff --git a/spec/services/discovery_engine/query/search_spec.rb b/spec/services/discovery_engine/query/search_spec.rb index 50e4336..324e4c3 100644 --- a/spec/services/discovery_engine/query/search_spec.rb +++ b/spec/services/discovery_engine/query/search_spec.rb @@ -153,7 +153,7 @@ end end - context "when searching for a query that has a single best bets defined" do + context "when searching for a query that has a single best bet defined" do # see test section in YAML config let(:query_params) { { q: "i want to test a single best bet" } } @@ -171,6 +171,24 @@ end end + context "when searching for a query with a best bet in a different case and whitespace" do + # see test section in YAML config + let(:query_params) { { q: " I want to TEST a sInGlE best bET " } } + + let(:expected_boost_specs) do + super() + [{ + boost: 1, + condition: 'link: ANY("/here/you/go")', + }] + end + + it "calls the client with the expected parameters" do + expect(client).to have_received(:search).with( + hash_including(boost_spec: { condition_boost_specs: expected_boost_specs }), + ) + end + end + context "when searching for a query that has multiple best bets defined" do # see test section in YAML config let(:query_params) { { q: "i want to test multiple best bets" } }