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:
Mark VanLandingham
2024-12-05 08:31:05 -06:00
committed by GitHub
parent 555ca4da55
commit 68e57190df
7 changed files with 101 additions and 0 deletions

View File

@ -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