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:
parent
fd9a5bc023
commit
eeecb2460d
|
@ -732,12 +732,11 @@ class Post < ActiveRecord::Base
|
||||||
before_save do
|
before_save do
|
||||||
self.last_editor_id ||= user_id
|
self.last_editor_id ||= user_id
|
||||||
|
|
||||||
if !new_record? && will_save_change_to_raw?
|
if will_save_change_to_raw?
|
||||||
self.cooked = cook(raw, topic_id: topic_id)
|
self.cooked = cook(raw, topic_id: topic_id) if !new_record?
|
||||||
|
self.baked_at = Time.zone.now
|
||||||
|
self.baked_version = BAKED_VERSION
|
||||||
end
|
end
|
||||||
|
|
||||||
self.baked_at = Time.zone.now
|
|
||||||
self.baked_version = BAKED_VERSION
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def advance_draft_sequence
|
def advance_draft_sequence
|
||||||
|
|
|
@ -191,7 +191,8 @@ class PostMover
|
||||||
post_number: @move_map[post.post_number],
|
post_number: @move_map[post.post_number],
|
||||||
reply_to_post_number: @move_map[post.reply_to_post_number],
|
reply_to_post_number: @move_map[post.reply_to_post_number],
|
||||||
topic_id: destination_topic.id,
|
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]
|
unless @move_map[post.reply_to_post_number]
|
||||||
|
|
|
@ -120,7 +120,8 @@ describe PostMover do
|
||||||
.to change { p2.reload.topic_id }
|
.to change { p2.reload.topic_id }
|
||||||
.and change { p2.post_number }
|
.and change { p2.post_number }
|
||||||
.and change { p3.reload.raw }
|
.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}")
|
expect(p3.raw).to include("post:#{p2.post_number}, topic:#{p2.topic_id}")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue