Do not render proposals geozones when empty

This commit is contained in:
Senén Rodero Rodríguez
2023-06-19 11:12:24 +02:00
parent e4cd02c6a9
commit ca12388005
3 changed files with 23 additions and 0 deletions

View File

@@ -1,4 +1,7 @@
class Proposals::GeozonesComponent < ApplicationComponent
delegate :image_path_for, to: :helpers
def render?
Geozone.any?
end
end

View File

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

View File

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