From 2d6e215569df12b064a711620ab3d8eefcd1aa47 Mon Sep 17 00:00:00 2001 From: JG Date: Fri, 10 Jun 2022 09:48:00 +0100 Subject: [PATCH] correct return when on org schemes --- app/components/search_component.rb | 2 ++ .../requests/organisations_controller_spec.rb | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/components/search_component.rb b/app/components/search_component.rb index eefdc5309..b08c1039a 100644 --- a/app/components/search_component.rb +++ b/app/components/search_component.rb @@ -13,6 +13,8 @@ class SearchComponent < ViewComponent::Base request.path elsif request.path.include?("organisations") && request.path.include?("logs") request.path + elsif request.path.include?("organisations") && request.path.include?("supported-housing") + request.path elsif request.path.include?("users") user_path(current_user) elsif request.path.include?("organisations") diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 5fc6cd94a..beacd3d32 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -63,6 +63,30 @@ RSpec.describe OrganisationsController, type: :request do expect(page).not_to have_content(scheme.code) end end + + context "when searching" do + let!(:searched_scheme) { FactoryBot.create(:scheme, code: "CODE321") } + let(:search_param) { "CODE321" } + + before do + get "/organisations/#{organisation.id}/supported-housing?search=#{search_param}" + end + + it "returns matching results" do + expect(page).to have_content(searched_scheme.code) + schemes.each do |scheme| + expect(page).not_to have_content(scheme.code) + end + end + + it "updates the table caption" do + expect(page).to have_content("1 scheme found matching ‘#{search_param}’") + end + + it "has search in the title" do + expect(page).to have_title("Supported housing services (1 scheme matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + end + end end describe "#show" do