Fix edge case
The user was able to vote as many investments as wanted in the first heading voted. However in the second heading voted, only one investment could be voted This was due to the previous implementation, where you could only vote in one heading. Note the `first` call in method `heading_voted_by_user?(user)` This commits simplifies the logic and allows voting for any investment in any heading that the user has previously voted in
This commit is contained in:
@@ -231,7 +231,7 @@ class Budget
|
||||
end
|
||||
|
||||
def valid_heading?(user)
|
||||
voted_in?([heading.id], user) ||
|
||||
voted_in?(heading, user) ||
|
||||
can_vote_in_another_heading?(user)
|
||||
end
|
||||
|
||||
@@ -243,13 +243,8 @@ class Budget
|
||||
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
|
||||
|
||||
def heading_voted_by_user?(user)
|
||||
user.votes.for_budget_investments(budget.investments.where(group: group))
|
||||
.votables.map(&:heading_id).first
|
||||
def voted_in?(heading, user)
|
||||
headings_voted_by_user(user).include?(heading.id)
|
||||
end
|
||||
|
||||
def ballotable_by?(user)
|
||||
|
||||
Reference in New Issue
Block a user