Do not render proposals geozones when empty
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
class Proposals::GeozonesComponent < ApplicationComponent
|
class Proposals::GeozonesComponent < ApplicationComponent
|
||||||
delegate :image_path_for, to: :helpers
|
delegate :image_path_for, to: :helpers
|
||||||
|
|
||||||
|
def render?
|
||||||
|
Geozone.any?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
19
spec/components/proposals/geozones_component_spec.rb
Normal file
19
spec/components/proposals/geozones_component_spec.rb
Normal 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
|
||||||
@@ -31,6 +31,7 @@ describe "Admin custom images", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Image is replaced on front views" do
|
scenario "Image is replaced on front views" do
|
||||||
|
create(:geozone)
|
||||||
budget = create(:budget)
|
budget = create(:budget)
|
||||||
group = create(:budget_group, budget: budget)
|
group = create(:budget_group, budget: budget)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user