]> cat aescling's git repositories - mastodon.git/commitdiff
Fix vote validation for polls with multiple choices (#10138)
authorEugen Rochko <eugen@zeonfederated.com>
Sun, 3 Mar 2019 22:41:30 +0000 (23:41 +0100)
committerGitHub <noreply@github.com>
Sun, 3 Mar 2019 22:41:30 +0000 (23:41 +0100)
app/validators/vote_validator.rb

index e2a68d1f38134e647392ee082fa7a44091c43459..2e1818bdb94d3b557efaf726b02f0a6d7f03a90f 100644 (file)
@@ -6,7 +6,7 @@ class VoteValidator < ActiveModel::Validator
 
     if vote.poll.multiple? && vote.poll.votes.where(account: vote.account, choice: vote.choice).exists?
       vote.errors.add(:base, I18n.t('polls.errors.already_voted'))
-    elsif vote.poll.votes.where(account: vote.account).exists?
+    elsif !vote.poll.multiple? && vote.poll.votes.where(account: vote.account).exists?
       vote.errors.add(:base, I18n.t('polls.errors.already_voted'))
     end
   end