diff --git a/app/components/budgets/investments/votes_component.rb b/app/components/budgets/investments/votes_component.rb index 57a948bca..0d7bd97b9 100644 --- a/app/components/budgets/investments/votes_component.rb +++ b/app/components/budgets/investments/votes_component.rb @@ -45,7 +45,7 @@ class Budgets::Investments::VotesComponent < ApplicationComponent def display_support_alert? current_user && !current_user.voted_in_group?(investment.group) && - investment.group.headings.count > 1 + investment.group.headings.count > investment.group.max_votable_headings end def confirm_vote_message diff --git a/spec/system/budgets/votes_spec.rb b/spec/system/budgets/votes_spec.rb index 2a9de4659..8c38b5d23 100644 --- a/spec/system/budgets/votes_spec.rb +++ b/spec/system/budgets/votes_spec.rb @@ -198,6 +198,16 @@ describe "Votes" do expect(page.driver.send(:find_modal).text).to match "You can only support investments in 2 districts." end + + scenario "Do not show confirm message if user can vote in all headings" do + group.update!(max_votable_headings: group.headings.count) + + visit budget_investments_path(budget, heading_id: new_york.id) + click_button "Support" + + expect(page).to have_content "1 support" + expect(page).to have_content "You have already supported this investment project. Share it!" + end end end