diff --git a/app/components/proposals/geozones_component.rb b/app/components/proposals/geozones_component.rb index d0379f8dc..46021ca2c 100644 --- a/app/components/proposals/geozones_component.rb +++ b/app/components/proposals/geozones_component.rb @@ -1,4 +1,7 @@ class Proposals::GeozonesComponent < ApplicationComponent delegate :image_path_for, to: :helpers + def render? + Geozone.any? + end end diff --git a/spec/components/proposals/geozones_component_spec.rb b/spec/components/proposals/geozones_component_spec.rb new file mode 100644 index 000000000..af6284ff7 --- /dev/null +++ b/spec/components/proposals/geozones_component_spec.rb @@ -0,0 +1,19 @@ +require "rails_helper" + +describe Proposals::GeozonesComponent do + let(:component) { Proposals::GeozonesComponent.new() } + + it "is not rendered when there are no geozones defined" do + render_inline component + + expect(page).not_to have_content "Districts" + end + + it "is rendered when there are geozones defined" do + create(:geozone) + + render_inline component + + expect(page).to have_content "Districts" + end +end diff --git a/spec/system/admin/site_customization/images_spec.rb b/spec/system/admin/site_customization/images_spec.rb index 85f3736ee..9e0a1a142 100644 --- a/spec/system/admin/site_customization/images_spec.rb +++ b/spec/system/admin/site_customization/images_spec.rb @@ -31,6 +31,7 @@ describe "Admin custom images", :admin do end scenario "Image is replaced on front views" do + create(:geozone) budget = create(:budget) group = create(:budget_group, budget: budget)