mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 17:40:43 +08:00
DEV: Allow freeze_original
argument in topics controller & JS transformer (#30120)
PostMover has a new option called freeze_original implemented in this commit. It was previously unexposed in the controller. This PR permits the param in the controller, and passes it into PostMover. Also, this applies a value transformer for move/merge payload options. In addition a plugin outlet in the move post modal. This allows plugins to add content to the modal, which can modify the payload (and use the freeze_original argument for example)
This commit is contained in:

committed by
GitHub

parent
555ca4da55
commit
68e57190df
@ -166,6 +166,21 @@ RSpec.describe TopicsController do
|
||||
expect(Tag.all.pluck(:name)).to include("foo", "bar")
|
||||
end
|
||||
|
||||
describe "with freeze_original param" do
|
||||
it "duplicates post to new topic and keeps original post in place" do
|
||||
expect do
|
||||
post "/t/#{topic.id}/move-posts.json",
|
||||
params: {
|
||||
title: "Logan is a good movie",
|
||||
post_ids: [p2.id],
|
||||
freeze_original: true,
|
||||
}
|
||||
end.to change { Topic.count }.by(1)
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.post_ids).to include(p2.id)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when topic has been deleted" do
|
||||
it "should still be able to move posts" do
|
||||
PostDestroyer.new(admin, topic.first_post).destroy
|
||||
@ -308,6 +323,22 @@ RSpec.describe TopicsController do
|
||||
expect(result["url"]).to be_present
|
||||
end
|
||||
|
||||
describe "with freeze_original param" do
|
||||
it "duplicates post to topic and keeps original post in place" do
|
||||
expect do
|
||||
post "/t/#{topic.id}/move-posts.json",
|
||||
params: {
|
||||
post_ids: [p2.id],
|
||||
destination_topic_id: dest_topic.id,
|
||||
freeze_original: true,
|
||||
}
|
||||
end.to change { dest_topic.posts.count }.by(1)
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.post_ids).to include(p2.id)
|
||||
expect(dest_topic.posts.find_by(raw: p2.raw)).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
it "triggers an event on merge" do
|
||||
begin
|
||||
called = false
|
||||
|
Reference in New Issue
Block a user