DEV: API for plugins to add post update params and handlers (#12505)

This commit is contained in:
Mark VanLandingham
2021-03-24 10:22:16 -05:00
committed by GitHub
parent e7fb45cc29
commit 371afc45e0
5 changed files with 47 additions and 1 deletions

View File

@@ -527,6 +527,34 @@ describe PostsController do
expect(response.status).to eq(403)
expect(post.topic.reload.category_id).not_to eq(category.id)
end
describe "with Post.plugin_permitted_update_params" do
before do
plugin = Plugin::Instance.new
plugin.add_permitted_post_update_param(:random_number) do |post, value|
post.custom_fields[:random_number] = value
post.save
end
end
after do
DiscoursePluginRegistry.reset!
end
it "calls blocks passed into `add_permitted_post_update_param`" do
sign_in(post.user)
put "/posts/#{post.id}.json", params: {
post: {
raw: "this is a random post",
raw_old: post.raw,
random_number: 244
}
}
expect(response.status).to eq(200)
expect(post.reload.custom_fields[:random_number]).to eq("244")
end
end
end
describe "#destroy_bookmark" do