mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
FIX: Revised post not updated correctly when merging posts.
This commit is contained in:
parent
748a9e008f
commit
6288d4c995
|
@ -27,9 +27,9 @@ class PostMerger
|
|||
edit_reason: I18n.t("merge_posts.edit_reason", count: posts.length, username: @user.username)
|
||||
}
|
||||
|
||||
Post.transaction do
|
||||
revisor = PostRevisor.new(post, post.topic)
|
||||
revisor.revise!(@user, changes, {})
|
||||
revisor = PostRevisor.new(post, post.topic)
|
||||
|
||||
revisor.revise!(@user, changes) do
|
||||
posts.each { |p| PostDestroyer.new(@user, p).destroy }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -137,6 +137,7 @@ class PostRevisor
|
|||
Post.transaction do
|
||||
revise_post
|
||||
|
||||
yield if block_given?
|
||||
# TODO: these callbacks are being called in a transaction
|
||||
# it is kind of odd, because the callback is called "before_edit"
|
||||
# but the post is already edited at this point
|
||||
|
|
|
@ -15,7 +15,11 @@ describe PostMerger do
|
|||
reply3 = create_post(topic: topic, raw: 'The third reply', post_number: 4, user: user)
|
||||
replies = [reply3, reply2, reply1]
|
||||
|
||||
PostMerger.new(admin, replies).merge
|
||||
message = MessageBus.track_publish { PostMerger.new(admin, replies).merge }.last
|
||||
|
||||
expect(message.channel).to eq("/topic/#{topic.id}")
|
||||
expect(message.data[:type]).to eq(:revised)
|
||||
expect(message.data[:post_number]).to eq(reply3.post_number)
|
||||
|
||||
expect(reply1.trashed?).to eq(true)
|
||||
expect(reply2.trashed?).to eq(true)
|
||||
|
|
Loading…
Reference in New Issue
Block a user