Note that in the budgets wizard test we now create district with no associated geozone, so the text "all city" will appear in the districts table too, meaning we can't use `within "section", text: "All city" do` anymore since it would result in an ambiguous match. Co-Authored-By: Julian Herrero <microweb10@gmail.com> Co-Authored-By: Javi Martín <javim@elretirao.net>
57 lines
1.7 KiB
Ruby
57 lines
1.7 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Budgets::MapComponent do
|
|
before { Setting["feature.map"] = true }
|
|
let(:budget) { create(:budget, :accepting) }
|
|
|
|
describe "#render?" do
|
|
let(:budget) { build(:budget) }
|
|
|
|
it "is rendered after the informing phase when the map feature is enabled" do
|
|
budget.phase = "accepting"
|
|
|
|
render_inline Budgets::MapComponent.new(budget)
|
|
|
|
expect(page.find(".budgets-map")).to have_content "located geographically"
|
|
end
|
|
|
|
it "is not rendered during the informing phase" do
|
|
budget.phase = "informing"
|
|
|
|
render_inline Budgets::MapComponent.new(budget)
|
|
|
|
expect(page).not_to be_rendered
|
|
end
|
|
|
|
it "is not rendered when the map feature is disabled" do
|
|
Setting["feature.map"] = false
|
|
budget.phase = "accepting"
|
|
|
|
render_inline Budgets::MapComponent.new(budget)
|
|
|
|
expect(page).not_to be_rendered
|
|
end
|
|
end
|
|
|
|
describe "#geozones_data" do
|
|
it "renders data for the geozones associated with the budget" do
|
|
create(:budget_heading, geozone: create(:geozone, color: "#0000ff"), budget: budget)
|
|
create(:budget_heading, geozone: create(:geozone, color: "#ff0000"), budget: create(:budget))
|
|
|
|
render_inline Budgets::MapComponent.new(budget)
|
|
|
|
expect(page).to have_css "[data-geozones*='#0000ff']"
|
|
expect(page).not_to have_css "[data-geozones*='#ff0000']"
|
|
end
|
|
|
|
it "renders empty geozone data when there are no geozones" do
|
|
create(:budget_heading, geozone: nil, budget: budget)
|
|
create(:budget_heading, geozone: create(:geozone, color: "#ff0000"), budget: create(:budget))
|
|
|
|
render_inline Budgets::MapComponent.new(budget)
|
|
|
|
expect(page).to have_css "[data-geozones='[]']"
|
|
end
|
|
end
|
|
end
|