Add headings_voted_by_user
This method was used only in Madrid’s fork, but it is now needed to complete the backport for voting in multiple headings There wasn’t a test in Madrid, so here goes one too. Even though, the responsibility should probably be moved soon to the `Budget::Heading`. For consistency with the related methods and tests it has been left in the investment_spec
This commit is contained in:
@@ -239,6 +239,10 @@ class Budget
|
||||
headings_voted_by_user(user).count < group.max_votable_headings
|
||||
end
|
||||
|
||||
def headings_voted_by_user(user)
|
||||
user.votes.for_budget_investments(budget.investments.where(group: group)).votables.map(&:heading_id).uniq
|
||||
end
|
||||
|
||||
def voted_in?(heading_ids, user)
|
||||
heading_ids.include? heading_voted_by_user?(user)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user