Skip to content

Commit

Permalink
FIX: merge votes regardless of voters' visibility (#187)
Browse files Browse the repository at this point in the history
Ensures merging topics also merges votes regardless of the voters' visibility (when voting_show_who_voted site setting is false).
  • Loading branch information
renato committed May 2, 2024
1 parent f9654ee commit 0ae9350
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugin.rb
Expand Up @@ -179,8 +179,9 @@ class Engine < ::Rails::Engine
moved_votes = 0
duplicated_votes = 0

if orig.who_voted.present? && orig.closed
orig.who_voted.each do |user|
who_voted = orig.votes.map(&:user)
if who_voted.present? && orig.closed
who_voted.each do |user|
next if user.blank?

user_votes = user.topics_with_vote.pluck(:topic_id)
Expand Down
3 changes: 3 additions & 0 deletions spec/voting_spec.rb
Expand Up @@ -36,6 +36,9 @@
let(:users) { [user0, user1, user2, user3, user4, user5] }

before do
# ensure merging votes works regardless of voters' visibility
SiteSetting.voting_show_who_voted = false

Fabricate(:post, topic: topic0, user: user0)
Fabricate(:post, topic: topic0, user: user0)

Expand Down

0 comments on commit 0ae9350

Please sign in to comment.