Fix crash voting on a heading with a content block
When voting investment projects, the sidebar was rendered without the `@heading_content_blocks` being set. That resulted in a 500 error when the heading had content blocks. By extracting the logic to a component, we make sure the heading content blocks are properly set every time this code is rendered, no matter which controller is rendering the view.
This commit is contained in:
@@ -160,13 +160,16 @@ describe "Ballots" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "the Map shoud be visible before and after" do
|
||||
scenario "map and content block shoud be visible before and after" do
|
||||
create(:budget_investment, :selected, heading: new_york, price: 10000, title: "More bridges")
|
||||
create(:heading_content_block, heading: new_york, body: "<li>New Block</li>")
|
||||
new_york.update!(allow_custom_content: true)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: new_york)
|
||||
|
||||
within("#sidebar") do
|
||||
expect(page).to have_content "OpenStreetMap"
|
||||
expect(page).to have_content "New Block"
|
||||
end
|
||||
|
||||
add_to_ballot("More bridges")
|
||||
@@ -174,6 +177,7 @@ describe "Ballots" do
|
||||
within("#sidebar") do
|
||||
expect(page).to have_content "More bridges"
|
||||
expect(page).to have_content "OpenStreetMap"
|
||||
expect(page).to have_content "New Block"
|
||||
end
|
||||
|
||||
within(".budget-investment", text: "More bridges") do
|
||||
@@ -183,6 +187,7 @@ describe "Ballots" do
|
||||
within("#sidebar") do
|
||||
expect(page).not_to have_content "More bridges"
|
||||
expect(page).to have_content "OpenStreetMap"
|
||||
expect(page).to have_content "New Block"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user