Add the geozone name to the proposal partial when there are geozones defined

As we have links pointing to a search by geozone name I
think we should show somewhere the geozone where the
proposal belongs.
This commit is contained in:
Senén Rodero Rodríguez
2023-06-14 12:35:14 +02:00
parent 1bc2a68856
commit 37695cd262
3 changed files with 33 additions and 0 deletions

View File

@@ -53,6 +53,13 @@
<%= t("shared.collective") %>
</span>
<% end %>
<% if Geozone.any? %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="geozone">
<%= link_to geozone_name(proposal), legislation_process_proposals_path(proposal.legislation_process_id, search: geozone_name(proposal)) %>
</span>
<% end %>
</p>
<div class="proposal-description">
<p><%= proposal.summary %></p>

View File

@@ -52,6 +52,13 @@
<%= t("shared.collective") %>
</span>
<% end %>
<% if Geozone.any? %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="geozone">
<%= link_to geozone_name(proposal), proposals_path(search: geozone_name(proposal)) %>
</span>
<% end %>
</p>
<div class="proposal-description">
<p><%= proposal.summary %></p>

View File

@@ -237,6 +237,25 @@ describe "Legislation Proposals" do
expect(page).to have_link("Culture")
end
scenario "Shows geozone tag as proposals filter where there are geozones defined" do
create(:legislation_proposal, process: process)
create(:legislation_proposal, process: process, geozone: create(:geozone, name: "Zone1"))
visit legislation_process_proposals_path(process)
expect(page).to have_link("Zone1", href: legislation_process_proposals_path(process, search: "Zone1"))
link = legislation_process_proposals_path(process, search: "All city")
expect(page).to have_link("All city", href: link)
end
scenario "Does not show the geozone tag when no geozones defined" do
create(:legislation_proposal, process: process)
visit legislation_process_proposals_path(process)
expect(page).not_to have_link("All city")
end
scenario "Can filter proposals by geozone" do
geozone = create(:geozone, name: "Zone1")
proposal = create(:legislation_proposal, title: "Proposal with geozone",