FIX: Copy custom fields when moving first post of a topic.
https://meta.discourse.org/t/transfer-poll-votes-when-moving-a-topic-into-an-existing-one/63678
This commit is contained in:
parent
860a7e1fc0
commit
5794ff53a1
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue