diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 91038dbc9..2df2d21b1 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -139,6 +139,10 @@ module FiltersHelper request.path.include?("/lettings-logs") end + def specific_organisation_path? + request.path.include?("/organisations") + end + def applied_filters_count(filter_type) filters_count(applied_filters(filter_type)) end diff --git a/app/views/schemes/_scheme_filters.html.erb b/app/views/schemes/_scheme_filters.html.erb index 6e66e38ba..af9ed093f 100644 --- a/app/views/schemes/_scheme_filters.html.erb +++ b/app/views/schemes/_scheme_filters.html.erb @@ -5,13 +5,13 @@
- <%= form_with url: schemes_path, html: { method: :get } do |f| %> + <%= form_with url: specific_organisation_path? ? schemes_organisation_path(@organisation) : schemes_path, html: { method: :get } do |f| %>

<%= filters_applied_text(@filter_type) %>

- <%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %> + <%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>

diff --git a/app/views/users/_user_filters.html.erb b/app/views/users/_user_filters.html.erb index 9547cbc86..d047beac7 100644 --- a/app/views/users/_user_filters.html.erb +++ b/app/views/users/_user_filters.html.erb @@ -5,13 +5,13 @@
- <%= form_with url: users_path, html: { method: :get } do |f| %> + <%= form_with url: specific_organisation_path? ? users_organisation_path(@organisation) : users_path, html: { method: :get } do |f| %>

<%= filters_applied_text(@filter_type) %>

- <%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %> + <%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>

diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index d7a9609f8..5d57b31e6 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -81,7 +81,7 @@ RSpec.describe "Schemes scheme Features" do it "displays the filters component with a correct count and clear button" do expect(page).to have_content("2 filters applied") - expect(page).to have_link("Clear", href: "/clear-filters?filter_type=schemes") + expect(page).to have_link("Clear", href: /clear-filters\?filter_type=schemes/) end context "when clearing the filters" do diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index ce0e1317f..2da53970b 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -252,7 +252,7 @@ RSpec.describe "User Features" do context "when no filters are selected" do it "displays the filters component with no clear button" do expect(page).to have_content("No filters applied") - expect(page).not_to have_link("Clear", href: "/clear-filters?filter_type=users") + expect(page).not_to have_link("Clear", href: /clear-filters\?filter_type=users/) end end @@ -265,7 +265,7 @@ RSpec.describe "User Features" do it "displays the filters component with a correct count and clear button" do expect(page).to have_content("2 filters applied") - expect(page).to have_link("Clear", href: "/clear-filters?filter_type=users") + expect(page).to have_link("Clear", href: /clear-filters\?filter_type=users/) end context "when clearing the filters" do