mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: Never return the same reply more than once via reply_ids
If our reply tree somehow ends up with cycles or other odd structures, we only want to consider a reply once, at the first level in the tree that it appears.
This commit is contained in:
@ -956,6 +956,11 @@ describe Post do
|
||||
expect(p1.reply_ids).to be_blank
|
||||
end
|
||||
|
||||
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" do
|
||||
expect(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 }])
|
||||
|
Reference in New Issue
Block a user