From a6b186690885844f2469a38b3d6575fec2e14cac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?=
<15726+Senen@users.noreply.github.com>
Date: Mon, 12 Jun 2023 13:57:00 +0200
Subject: [PATCH] Allow to pass the destination link for the geozone link
Previous to this commit the geozone link shown in the
legislation proposal page was pointing to the proposals
process feature instead to the legislation proposals.
---
.../shared/geozone_link_component.html.erb | 2 +-
app/components/shared/geozone_link_component.rb | 5 +++--
app/views/legislation/proposals/show.html.erb | 2 +-
app/views/proposals/show.html.erb | 2 +-
spec/system/legislation/proposals_spec.rb | 15 +++++++++++++++
5 files changed, 21 insertions(+), 5 deletions(-)
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 @@
-
- <%= link_to geozone_name(geozonable), proposals_path(search: geozone_name(geozonable)) %>
+ <%= link_to geozone_name(geozonable), link %>
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