Do not show confirm message if user can vote in all headings

This commit is contained in:
decabeza
2021-07-14 16:14:29 +02:00
parent 3f9614fbe1
commit e42db48f2b
2 changed files with 11 additions and 1 deletions

View File

@@ -45,7 +45,7 @@ class Budgets::Investments::VotesComponent < ApplicationComponent
def display_support_alert? def display_support_alert?
current_user && current_user &&
!current_user.voted_in_group?(investment.group) && !current_user.voted_in_group?(investment.group) &&
investment.group.headings.count > 1 investment.group.headings.count > investment.group.max_votable_headings
end end
def confirm_vote_message def confirm_vote_message

View File

@@ -198,6 +198,16 @@ describe "Votes" do
expect(page.driver.send(:find_modal).text).to match "You can only support investments in 2 districts." expect(page.driver.send(:find_modal).text).to match "You can only support investments in 2 districts."
end 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
end end