Fix investments link in single heading budgets

The link to "See all investments" didn't have the `heading_id`
parameter, which resulted in the ballot information not being displayed
when in the voting phase.

We could modify the link to include the `heading_id` parameter, but IMHO
it's more robust to select the heading automatically when there's only
one heading. That way manually accessing the page without a `heading_id`
parameter will still work as if the heading had been selected.
This commit is contained in:
Javi Martín
2021-09-17 00:55:37 +02:00
parent f669b476f8
commit caebaac1cc
2 changed files with 6 additions and 0 deletions

View File

@@ -135,6 +135,9 @@ module Budgets
@heading = @budget.headings.find_by_slug_or_id! params[:heading_id] @heading = @budget.headings.find_by_slug_or_id! params[:heading_id]
@assigned_heading = @ballot&.heading_for_group(@heading.group) @assigned_heading = @ballot&.heading_for_group(@heading.group)
load_map load_map
elsif @budget.single_heading?
@heading = @budget.headings.first
load_map
end end
end end

View File

@@ -1356,6 +1356,9 @@ describe "Budget Investments" do
expect(page).to have_content investment2.title expect(page).to have_content investment2.title
expect(page).to have_content "€20,000" expect(page).to have_content "€20,000"
end end
expect(page).to have_link "Submit my ballot"
expect(page).to have_content "STILL AVAILABLE TO YOU €666,666"
end end
scenario "Order by cost (only when balloting)" do scenario "Order by cost (only when balloting)" do