FIX: nil the baked version after moving the posts. (#14483)

Previosuly, quotes from original topics are rendered incorrectly since the moved posts are not rebaked.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
Vinoth Kannan 2021-10-12 12:01:18 +05:30 committed by GitHub
parent fd9a5bc023
commit eeecb2460d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -732,12 +732,11 @@ class Post < ActiveRecord::Base
before_save do
self.last_editor_id ||= user_id
if !new_record? && will_save_change_to_raw?
self.cooked = cook(raw, topic_id: topic_id)
if will_save_change_to_raw?
self.cooked = cook(raw, topic_id: topic_id) if !new_record?
self.baked_at = Time.zone.now
self.baked_version = BAKED_VERSION
end
self.baked_at = Time.zone.now
self.baked_version = BAKED_VERSION
end
def advance_draft_sequence

View File

@ -191,7 +191,8 @@ class PostMover
post_number: @move_map[post.post_number],
reply_to_post_number: @move_map[post.reply_to_post_number],
topic_id: destination_topic.id,
sort_order: @move_map[post.post_number]
sort_order: @move_map[post.post_number],
baked_version: nil
}
unless @move_map[post.reply_to_post_number]

View File

@ -120,7 +120,8 @@ describe PostMover do
.to change { p2.reload.topic_id }
.and change { p2.post_number }
.and change { p3.reload.raw }
.and change { p3.baked_version }.to nil
.and change { p2.baked_version }.to(nil)
.and change { p3.baked_version }.to(nil)
expect(p3.raw).to include("post:#{p2.post_number}, topic:#{p2.topic_id}")
end