Display already voted message for budget polls
Budget polls behave slightly differently to non-budget polls. In budget polls we use Budget::Ballot::Lines to verify if a user has already voted online. In non-budget polls we use Poll::Voter to verify this. In this commit we are adding an extra check to make sure that the correct message is displayed if the user has already voted online for a budget poll[1] [1] https://github.com/AyuntamientoMadrid/consul/blob/master/spec/features/budget_polls/voter_spec.rb#L122
This commit is contained in:
committed by
Javi Martín
parent
5abde6da6e
commit
e1141d1cd3
@@ -91,12 +91,12 @@ class Poll < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def votable_by?(user)
|
def votable_by?(user)
|
||||||
return false if user_has_an_online_ballot(user)
|
return false if user_has_an_online_ballot?(user)
|
||||||
answerable_by?(user) &&
|
answerable_by?(user) &&
|
||||||
not_voted_by?(user)
|
not_voted_by?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_has_an_online_ballot(user)
|
def user_has_an_online_ballot?(user)
|
||||||
budget.present? && budget.ballots.find_by(user: user)&.lines.present?
|
budget.present? && budget.ballots.find_by(user: user)&.lines.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<% if poll.votable_by?(@user) %>
|
<% if poll.votable_by?(@user) %>
|
||||||
<%= render "can_vote", poll: poll %>
|
<%= render "can_vote", poll: poll %>
|
||||||
<% elsif poll.voted_by?(@user) %>
|
<% elsif poll.voted_by?(@user) || poll.user_has_an_online_ballot?(@user) %>
|
||||||
<%= render "already_voted" %>
|
<%= render "already_voted" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render "cannot_vote" %>
|
<%= render "cannot_vote" %>
|
||||||
|
|||||||
Reference in New Issue
Block a user