From eb547f48612a78d6293de6bdf61cacb17ef7f361 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 14 Aug 2024 17:26:01 +1000 Subject: [PATCH] Add test on number of db queries Hmm, I think I seen an opportunity to clean up already. --- spec/lib/open_food_network/scope_variants_for_search_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/lib/open_food_network/scope_variants_for_search_spec.rb b/spec/lib/open_food_network/scope_variants_for_search_spec.rb index c8f6104ae5..99e011955b 100644 --- a/spec/lib/open_food_network/scope_variants_for_search_spec.rb +++ b/spec/lib/open_food_network/scope_variants_for_search_spec.rb @@ -65,6 +65,11 @@ RSpec.describe OpenFoodNetwork::ScopeVariantsForSearch do let(:params) { { q: "product", distributor_id: d2.id } } it "returns all products distributed through that distributor" do + expect{ result }.to query_database [ + "Enterprise Load", "Enterprise Load", "Enterprise Load", # loads same enterprise three times + "VariantOverride Load", + "SQL" + ] expect(result).to include v4 expect(result).not_to include v1, v2, v3 end