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.
This commit is contained in:
Senén Rodero Rodríguez
2023-06-12 13:57:00 +02:00
parent b3c294bb9a
commit a6b1866908
5 changed files with 21 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
<ul id="geozone" class="no-bullet geozone">
<li class="inline-block">
<%= link_to geozone_name(geozonable), proposals_path(search: geozone_name(geozonable)) %>
<%= link_to geozone_name(geozonable), link %>
</li>
</ul>

View File

@@ -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

View File

@@ -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))) %>
<div class="js-moderator-proposal-actions margin">
<%= render "legislation/proposals/actions", proposal: @proposal %>

View File

@@ -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 %>

View File

@@ -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