mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: API for plugins to add post update params and handlers (#12505)
This commit is contained in:
committed by
GitHub
parent
e7fb45cc29
commit
371afc45e0
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user