From 383f16467289c7deb69d3efde3df832c09ff0585 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 15 Mar 2022 10:51:10 +0100 Subject: [PATCH] FIX: Always include the first poster when converting to PM (#16187) Regressed in #15626 --- app/models/topic_converter.rb | 2 +- spec/models/topic_converter_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/topic_converter.rb b/app/models/topic_converter.rb index e9988ab89dc..21645753106 100644 --- a/app/models/topic_converter.rb +++ b/app/models/topic_converter.rb @@ -63,7 +63,7 @@ class TopicConverter private def posters - @posters ||= @topic.posts.where("post_number > 1").distinct.pluck(:user_id) + @posters ||= @topic.posts.distinct.pluck(:user_id) end def increment_users_post_count diff --git a/spec/models/topic_converter_spec.rb b/spec/models/topic_converter_spec.rb index 781c1eba408..f57dbac04ba 100644 --- a/spec/models/topic_converter_spec.rb +++ b/spec/models/topic_converter_spec.rb @@ -200,6 +200,11 @@ describe TopicConverter do expect(private_message.topic_allowed_users.count).to eq(1) end + it "includes the poster of a single-post topic" do + moderator = Fabricate(:moderator) + private_message = topic.convert_to_private_message(moderator) + expect(private_message.allowed_users).to match_array([topic.user, moderator]) + end end context 'topic has replies' do