From a49dadd28df8272ca82eceabf81d7180803a7b87 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 17 Jul 2023 09:00:49 +0100 Subject: [PATCH] feat: add new test --- spec/requests/lettings_logs_controller_spec.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 9f86a9836..66d13f988 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -774,7 +774,7 @@ RSpec.describe LettingsLogsController, type: :request do let(:tenant_code_2) { "TC8745" } before do - FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_1, tenancycode: tenant_code_1) + FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_1, tenancycode: tenant_code_1, created_by: user) FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_2, tenancycode: tenant_code_2) allow(user).to receive(:need_two_factor_authentication?).and_return(false) sign_in user @@ -799,6 +799,14 @@ RSpec.describe LettingsLogsController, type: :request do end end + context "when filtering by a specific user" do + it "only show the selected user's logs" do + get "/lettings-logs?assigned_to=you&user=#{user.id}", headers:, params: {} + expect(page).to have_content(tenant_code_1) + expect(page).not_to have_content(tenant_code_2) + end + end + context "when the support user has filtered by organisation, then switches back to all organisations" do it "shows all organisations" do get "http://localhost:3000/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&organisation_select=all&organisation=#{org_1.id}", headers:, params: {}