From 0ae9350771820729aed481a9ffcf5fb46553e570 Mon Sep 17 00:00:00 2001 From: Renato Atilio Date: Thu, 2 May 2024 10:40:51 -0300 Subject: [PATCH] FIX: merge votes regardless of voters' visibility (#187) Ensures merging topics also merges votes regardless of the voters' visibility (when voting_show_who_voted site setting is false). --- plugin.rb | 5 +++-- spec/voting_spec.rb | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin.rb b/plugin.rb index 44be931..3681dda 100755 --- a/plugin.rb +++ b/plugin.rb @@ -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) diff --git a/spec/voting_spec.rb b/spec/voting_spec.rb index 401faec..0b06fbf 100644 --- a/spec/voting_spec.rb +++ b/spec/voting_spec.rb @@ -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)