FEATURE: Allow users to remove their vote (#14459)

They can use the remove vote button or select the same option again for
single choice polls.

This commit refactor the plugin to properly organize code and make it
easier to follow.
This commit is contained in:
Bianca Nenciu
2021-10-05 11:38:49 +03:00
committed by GitHub
parent 12856ab8c2
commit 6a143030f8
13 changed files with 550 additions and 521 deletions

View File

@ -78,8 +78,8 @@ describe DiscoursePoll::PollsUpdater do
let(:post) { Fabricate(:post, raw: raw) }
it "works if poll is closed and unmodified" do
DiscoursePoll::Poll.vote(post.id, "poll", ["e55de753c08b93d04d677ce05e942d3c"], post.user)
DiscoursePoll::Poll.toggle_status(post.id, "poll", "closed", post.user)
DiscoursePoll::Poll.vote(post.user, post.id, "poll", ["e55de753c08b93d04d677ce05e942d3c"])
DiscoursePoll::Poll.toggle_status(post.user, post.id, "poll", "closed")
freeze_time (SiteSetting.poll_edit_window_mins + 1).minutes.from_now
update(post, DiscoursePoll::PollsValidator.new(post).validate_polls)
@ -159,7 +159,7 @@ describe DiscoursePoll::PollsUpdater do
before do
expect {
DiscoursePoll::Poll.vote(post.id, "poll", [polls["poll"]["options"][0]["id"]], user)
DiscoursePoll::Poll.vote(user, post.id, "poll", [polls["poll"]["options"][0]["id"]])
}.to change { PollVote.count }.by(1)
end