diff --git a/app/components/shared/geozone_link_component.html.erb b/app/components/shared/geozone_link_component.html.erb index 36ce1ebea..5a51ab78b 100644 --- a/app/components/shared/geozone_link_component.html.erb +++ b/app/components/shared/geozone_link_component.html.erb @@ -1,5 +1,5 @@ diff --git a/app/components/shared/geozone_link_component.rb b/app/components/shared/geozone_link_component.rb index 00c96f558..e7b4f23af 100644 --- a/app/components/shared/geozone_link_component.rb +++ b/app/components/shared/geozone_link_component.rb @@ -1,8 +1,9 @@ class Shared::GeozoneLinkComponent < ApplicationComponent - attr_reader :geozonable + attr_reader :geozonable, :link delegate :geozone_name, to: :helpers - def initialize(geozonable) + def initialize(geozonable, link) @geozonable = geozonable + @link = link end end diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index 58038f5a9..9969f1e96 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -94,7 +94,7 @@ <%= render "shared/tags", taggable: @proposal %> - <%= render Shared::GeozoneLinkComponent.new(@proposal) %> + <%= render Shared::GeozoneLinkComponent.new(@proposal, legislation_process_proposals_path(@process, search: geozone_name(@proposal))) %>
<%= render "legislation/proposals/actions", proposal: @proposal %> diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index ab65df0c7..ea2c5e844 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -40,7 +40,7 @@ <% end %> <%= render "proposals/info", proposal: @proposal %> - <%= render Shared::GeozoneLinkComponent.new(@proposal) %> + <%= render Shared::GeozoneLinkComponent.new(@proposal, proposals_path(search: geozone_name(@proposal))) %> <% unless @proposal.selected? %> <%= render "relationable/related_content", relationable: @proposal %> diff --git a/spec/system/legislation/proposals_spec.rb b/spec/system/legislation/proposals_spec.rb index 80eef133f..81cca1c30 100644 --- a/spec/system/legislation/proposals_spec.rb +++ b/spec/system/legislation/proposals_spec.rb @@ -236,4 +236,19 @@ describe "Legislation Proposals" do expect(page).to have_link("Culture") end + + scenario "Can filter proposals by geozone" do + geozone = create(:geozone, name: "Zone1") + proposal = create(:legislation_proposal, title: "Proposal with geozone", + legislation_process_id: process.id, + geozone: geozone) + create(:legislation_proposal, title: "Proposal without geozone", legislation_process_id: process.id) + + visit legislation_process_proposal_path(proposal.process, proposal) + click_link "Zone1" + + expect(page).to have_current_path(legislation_process_proposals_path(process.id, search: "Zone1")) + expect(page).to have_content("Proposal with geozone") + expect(page).not_to have_content("Proposal without geozone") + end end