From caebaac1cce081efd0760d9438935cc87f0450c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 17 Sep 2021 00:55:37 +0200 Subject: [PATCH] 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. --- app/controllers/budgets/investments_controller.rb | 3 +++ spec/system/budgets/investments_spec.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index e3d82cb6f..3953def8c 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -135,6 +135,9 @@ module Budgets @heading = @budget.headings.find_by_slug_or_id! params[:heading_id] @assigned_heading = @ballot&.heading_for_group(@heading.group) load_map + elsif @budget.single_heading? + @heading = @budget.headings.first + load_map end end diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index 002d17dc2..615cf78ec 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -1356,6 +1356,9 @@ describe "Budget Investments" do expect(page).to have_content investment2.title expect(page).to have_content "€20,000" end + + expect(page).to have_link "Submit my ballot" + expect(page).to have_content "STILL AVAILABLE TO YOU €666,666" end scenario "Order by cost (only when balloting)" do