mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FIX: Poll: ensure it is not possible to vote with all abstentions in Ranked Choice (#29601)
Make sure Cast Vote button is disabled when all abstain and remove any historic data that fails new zero rank vote validation
This commit is contained in:
@ -43,6 +43,36 @@ RSpec.describe DiscoursePoll::Poll do
|
||||
end.to raise_error(DiscoursePoll::Error, I18n.t("poll.one_vote_per_user"))
|
||||
end
|
||||
|
||||
it "should not allow a ranked vote with all abstentions" do
|
||||
poll = post_with_ranked_choice_poll.polls.first
|
||||
poll_options = poll.poll_options
|
||||
|
||||
expect do
|
||||
DiscoursePoll::Poll.vote(
|
||||
user,
|
||||
post_with_ranked_choice_poll.id,
|
||||
"poll",
|
||||
{
|
||||
"0": {
|
||||
digest: poll_options.first.digest,
|
||||
rank: "0",
|
||||
},
|
||||
"1": {
|
||||
digest: poll_options.second.digest,
|
||||
rank: "0",
|
||||
},
|
||||
"2": {
|
||||
digest: poll_options.third.digest,
|
||||
rank: "0",
|
||||
},
|
||||
},
|
||||
)
|
||||
end.to raise_error(
|
||||
DiscoursePoll::Error,
|
||||
I18n.t("poll.requires_that_at_least_one_option_is_ranked"),
|
||||
)
|
||||
end
|
||||
|
||||
it "should clean up bad votes for a regular poll" do
|
||||
poll = post_with_regular_poll.polls.first
|
||||
|
||||
|
Reference in New Issue
Block a user