Do not render the geozone link where there are no geozones defined
This commit is contained in:
@@ -6,4 +6,8 @@ class Shared::GeozoneLinkComponent < ApplicationComponent
|
|||||||
@geozonable = geozonable
|
@geozonable = geozonable
|
||||||
@link = link
|
@link = link
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render?
|
||||||
|
Geozone.any?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -251,4 +251,21 @@ describe "Legislation Proposals" do
|
|||||||
expect(page).to have_content("Proposal with geozone")
|
expect(page).to have_content("Proposal with geozone")
|
||||||
expect(page).not_to have_content("Proposal without geozone")
|
expect(page).not_to have_content("Proposal without geozone")
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -540,7 +540,15 @@ describe "Proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Geozones" do
|
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
|
scenario "Default whole city" do
|
||||||
|
create(:geozone)
|
||||||
author = create(:user)
|
author = create(:user)
|
||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user