From 9003c460d51ce98a25290a9ee402f8c46c5da2b6 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 14:56:03 +0200 Subject: [PATCH] Do not render the geozone link where there are no geozones defined --- app/components/shared/geozone_link_component.rb | 4 ++++ spec/system/legislation/proposals_spec.rb | 17 +++++++++++++++++ spec/system/proposals_spec.rb | 8 ++++++++ 3 files changed, 29 insertions(+) diff --git a/app/components/shared/geozone_link_component.rb b/app/components/shared/geozone_link_component.rb index e7b4f23af..33cac101b 100644 --- a/app/components/shared/geozone_link_component.rb +++ b/app/components/shared/geozone_link_component.rb @@ -6,4 +6,8 @@ class Shared::GeozoneLinkComponent < ApplicationComponent @geozonable = geozonable @link = link end + + def render? + Geozone.any? + end end diff --git a/spec/system/legislation/proposals_spec.rb b/spec/system/legislation/proposals_spec.rb index 81cca1c30..d270d8839 100644 --- a/spec/system/legislation/proposals_spec.rb +++ b/spec/system/legislation/proposals_spec.rb @@ -251,4 +251,21 @@ describe "Legislation Proposals" do expect(page).to have_content("Proposal with geozone") expect(page).not_to have_content("Proposal without geozone") end + + scenario "Show link to filter by geozone where there are geozones defined" do + create(:geozone) + create(:legislation_proposal, legislation_process_id: process.id) + + visit legislation_process_proposal_path(proposal.process, proposal) + + expect(page).to have_link("All city") + end + + scenario "Do not show link to geozone where there are no geozones defined" do + create(:legislation_proposal, legislation_process_id: process.id) + + visit legislation_process_proposal_path(proposal.process, proposal) + + expect(page).not_to have_link("All city") + end end diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index 19d7ffa9a..dcf046b07 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -540,7 +540,15 @@ describe "Proposals" do end context "Geozones" do + scenario "When there are not gezones defined it does not show the geozone link" do + visit proposal_path(create(:proposal)) + + expect(page).not_to have_selector "#geozone" + expect(page).not_to have_link "All city" + end + scenario "Default whole city" do + create(:geozone) author = create(:user) login_as(author)