Skip to content

Commit

Permalink
Merge pull request #385 from alphagov/dynamic-serving-config
Browse files Browse the repository at this point in the history
Make serving config optionally dynamic
  • Loading branch information
csutter authored Feb 7, 2025
2 parents 9bc12ba + 36fbdd9 commit 8a3ed9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/services/discovery_engine/query/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def query
end

def serving_config
ServingConfig.default.name
return ServingConfig.default.name if query_params[:serving_config].blank?

ServingConfig.new(query_params[:serving_config]).name
end

def page_size
Expand Down
10 changes: 10 additions & 0 deletions spec/services/discovery_engine/query/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@
)
end
end

context "when a serving config is manually specified" do
let(:query_params) { { q: "garden centres", serving_config: "preview" } }

it "calls the client with the expected parameters" do
expect(client).to have_received(:search).with(
hash_including(serving_config: ServingConfig.new("preview").name),
)
end
end
end
end
end

0 comments on commit 8a3ed9e

Please sign in to comment.