A platform for community discussion. Free, open, simple.
FIX: Never return the same reply more than once via reply_ids
Robin Ward37888d981845
diff --git a/app/models/post.rb b/app/models/post.rbindex 44368e538a0..0e582145e35 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -834,9 +834,10 @@ class Post < ActiveRecord::BaseWHERE r.reply_post_id <> r.post_idGROUP BY id, level)- SELECT id, level+ SELECT id, MIN(level) AS levelFROM breadcrumb_with_count/*where*/+ GROUP BY idORDER BY idSQLdiff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rbindex a97b2d561b2..33204e30f29 100644--- a/spec/models/post_spec.rb+++ b/spec/models/post_spec.rb@@ -956,6 +956,11 @@ describe Post doexpect(p1.reply_ids).to be_blankend+ it "doesn't include the same reply twice" do+ PostReply.create!(post: p4, reply: p1)+ expect(p1.reply_ids.size).to eq(4)+ end+it "does not skip any replies" doexpect(p1.reply_ids(only_replies_to_single_post: false)).to eq([{ id: p2.id, level: 1 }, { id: p4.id, level: 2 }, { id: p5.id, level: 3 }, { id: p6.id, level: 2 }])expect(p2.reply_ids(only_replies_to_single_post: false)).to eq([{ id: p4.id, level: 1 }, { id: p5.id, level: 2 }, { id: p6.id, level: 1 }])