FIX: on rebakes should not recreate quoted_posts records

Previously every rebake would remove and recreate records in this table
This caused created_at and updated_at to keep changing

Yes, I know the SQL is somewhat complex, but this makes quote extraction
more efficient cause we do everything in 2 round trips.

This also removes some concurrency protection we should no longer need
This commit is contained in:
Sam Saffron
2019-04-03 16:17:15 +11:00
parent 52c4711e80
commit b2dc65f953
2 changed files with 46 additions and 16 deletions

View File

@@ -70,11 +70,19 @@ describe QuotedPost do
HTML
QuotedPost.create!(post_id: post2.id, quoted_post_id: 999)
quote = QuotedPost.create!(post_id: post2.id, quoted_post_id: post1.id)
original_date = quote.created_at
freeze_time 1.hour.from_now
QuotedPost.extract_from(post2)
expect(QuotedPost.where(post_id: post2.id).count).to eq(1)
expect(QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id)).not_to eq(nil)
quote.reload
expect(original_date).to eq_time(quote.created_at)
expect(post2.reply_quoted).to eq(false)
end
end