mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
Add excerpt column to topics table to remove N+1 query in ListableTopicSerializer
This commit is contained in:
parent
3cf0adaed0
commit
0b1550f9d4
6 changed files with 50 additions and 5 deletions
|
@ -271,5 +271,21 @@ describe PostRevisor do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "topic excerpt" do
|
||||
it "topic excerpt is updated only if first post is revised" do
|
||||
revisor = described_class.new(post)
|
||||
first_post = topic.posts.by_post_number.first
|
||||
expect {
|
||||
revisor.revise!(first_post.user, 'Edit the first post', revised_at: first_post.updated_at + 10.seconds)
|
||||
topic.reload
|
||||
}.to change { topic.excerpt }
|
||||
second_post = Fabricate(:post, post_args.merge(post_number: 2, topic_id: topic.id))
|
||||
expect {
|
||||
described_class.new(second_post).revise!(second_post.user, 'Edit the 2nd post')
|
||||
topic.reload
|
||||
}.to_not change { topic.excerpt }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue