A platform for community discussion. Free, open, simple.
FIX: filter participation ignore small actions (#45304)
Bannon Tannerc38b12da3273
diff --git a/lib/topics_filter.rb b/lib/topics_filter.rbindex 3f3c321b64c..5ab624c069e 100644--- a/lib/topics_filter.rb+++ b/lib/topics_filter.rb@@ -522,6 +522,7 @@ class TopicsFilterWHERE p.topic_id = topics.idAND #{column} IN (#{ids.join(",")})AND p.deleted_at IS NULL+ AND p.post_type <> #{Post.types[:small_action]}#{whisper_condition("p")})SQLdiff --git a/spec/lib/topics_filter_spec.rb b/spec/lib/topics_filter_spec.rbindex 0abb80f33f5..6733afe6755 100644--- a/spec/lib/topics_filter_spec.rb+++ b/spec/lib/topics_filter_spec.rb@@ -323,6 +323,26 @@ RSpec.describe TopicsFilter doexpect(filtered("group:group1+group2")).not_to include(topic.id)end+ it "ignores small actions when matching participation" do+ topic = Fabricate(:post, user: u3).topic+ Fabricate(:small_action, topic:, user: u1)++ expect(filtered("users:alice")).not_to include(topic.id)+ expect(filtered("group:group1")).not_to include(topic.id)+ expect(filtered("-group:group1")).to include(topic.id)+ end++ it "does not match a topic just because a group member changed its status" do+ topic = Fabricate(:post, user: u3).topic+ topic.update_status("closed", true, u1)+ topic.update_status("closed", false, u1)++ expect(topic.posts.where(post_type: Post.types[:small_action], user_id: u1.id)).to exist++ expect(filtered("users:alice")).not_to include(topic.id)+ expect(filtered("group:group1")).not_to include(topic.id)+ end+context "with whispers" dofab!(:whisperer_group, :group)fab!(:whisperer_user) { Fabricate(:user).tap { |u| whisperer_group.add(u) } }@@ -341,6 +361,14 @@ RSpec.describe TopicsFilter doexpect(ids).to include(topic_by_u1.id, topic_by_u1_and_u2.id), queryendend++ it "counts whisper participation for whisperers" do+ %w[users:alice group:group1].each do |query|+ ids = filtered(query, Guardian.new(whisperer_user))++ expect(ids).to include(topic_with_whisper_only.id), query+ end+ endendend