diff --git a/app/models/post_mover.rb b/app/models/post_mover.rb index 657fc9bce3f..1f26293b2c5 100644 --- a/app/models/post_mover.rb +++ b/app/models/post_mover.rb @@ -95,6 +95,9 @@ class PostMover PostAction.copy(post, new_post) new_post.update_column(:reply_count, @reply_count[1] || 0) + new_post.custom_fields = post.custom_fields + new_post.save_custom_fields + new_post end def move(post) diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb index 52e1e02814a..24631d880c0 100644 --- a/spec/models/post_mover_spec.rb +++ b/spec/models/post_mover_spec.rb @@ -342,6 +342,16 @@ describe PostMover do expect(new_post.post_actions.size).to eq(1) end + it "preserves the custom_fields in the new post" do + custom_fields = { "some_field" => 'payload' } + p1.custom_fields = custom_fields + p1.save_custom_fields + + new_topic = topic.move_posts(user, [p1.id], title: "new testing topic name") + + expect(new_topic.first_post.custom_fields).to eq(custom_fields) + end + end context "to an existing topic with a deleted post" do