From e2032edd889f407dad4d27f20f611cd5d08a8259 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 17 Mar 2023 09:51:16 +0000 Subject: [PATCH] Filter on the subset of logs in tests (#1430) --- spec/services/filter_service_spec.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spec/services/filter_service_spec.rb b/spec/services/filter_service_spec.rb index 2c89b1302..6122550c9 100644 --- a/spec/services/filter_service_spec.rb +++ b/spec/services/filter_service_spec.rb @@ -29,13 +29,12 @@ describe FilterService do context "when filtering logs" do context "when filtering lettings logs" do - before do - FactoryBot.create_list(:lettings_log, 5) - FactoryBot.create(:lettings_log, postcode_full: "SW1 1AA") + let(:lettings_log_list) do + logs = FactoryBot.create_list(:lettings_log, 5) + searched_log = FactoryBot.create(:lettings_log, postcode_full: "SW1 1AA") + LettingsLog.where(id: [searched_log.id] + logs.map(&:id)) end - let(:lettings_log_list) { LettingsLog.all } - context "when given a postcode" do let(:search_term) { "SW1 1AA" } @@ -54,13 +53,12 @@ describe FilterService do end context "when filtering sales logs" do - before do - FactoryBot.create_list(:sales_log, 5) - FactoryBot.create(:sales_log, purchid: "2") + let(:sales_log_list) do + logs = FactoryBot.create_list(:sales_log, 5) + searched_log = FactoryBot.create(:sales_log, purchid: "2") + SalesLog.where(id: [searched_log.id] + logs.map(&:id)) end - let(:sales_log_list) { SalesLog.all } - context "when given a purchid" do let(:search_term) { "2" }