Ignore auto-quote/reply when counting replies

This commit is contained in:
Régis Hanol 2017-12-15 00:38:14 +01:00
parent f18dda2adc
commit b91f83eb7d
2 changed files with 3 additions and 4 deletions

View File

@ -673,6 +673,7 @@ class Post < ActiveRecord::Base
SELECT id, level, COUNT(*)
FROM post_replies, breadcrumb
WHERE reply_id = id
AND reply_id <> post_id
GROUP BY id, level
)
SELECT id, level FROM breadcrumb_with_count WHERE level > 0 AND count = 1 ORDER BY id

View File

@ -786,7 +786,6 @@ describe Post do
let!(:p4) { Fabricate(:post, topic: topic, post_number: 4, reply_to_post_number: 2) }
let!(:p5) { Fabricate(:post, topic: topic, post_number: 5, reply_to_post_number: 4) }
let!(:p6) { Fabricate(:post, topic: topic, post_number: 6) }
let!(:p7) { Fabricate(:post, topic: topic, post_number: 7) }
before {
PostReply.create!(post: p1, reply: p2)
@ -794,7 +793,7 @@ describe Post do
PostReply.create!(post: p2, reply: p6) # simulates p6 quoting p2
PostReply.create!(post: p3, reply: p5) # simulates p5 quoting p3
PostReply.create!(post: p4, reply: p5)
PostReply.create!(post: p7, reply: p7) # https://meta.discourse.org/t/topic-quoting-itself-displays-reply-indicator/76085
PostReply.create!(post: p6, reply: p6) # https://meta.discourse.org/t/topic-quoting-itself-displays-reply-indicator/76085
}
it "returns the reply ids and their level" do
@ -803,8 +802,7 @@ describe Post do
expect(p3.reply_ids).to be_empty # has no replies
expect(p4.reply_ids).to be_empty # p5 replies to 2 posts (p4 and p3)
expect(p5.reply_ids).to be_empty # has no replies
expect(p6.reply_ids).to be_empty # has no replies
expect(p7.reply_ids).to be_empty # quotes itself
expect(p6.reply_ids).to be_empty # quotes itself
end
end