A platform for community discussion. Free, open, simple.
FIX: Allow error handling for formats besides JSON (#27811)
Amanda Alves Branquinho7f0e6e959281
diff --git a/config/routes.rb b/config/routes.rbindex 75e292fdca8..fa711559e71 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -1107,7 +1107,7 @@ Discourse::Application.routes.draw doput "bookmarks/bulk"- resources :posts, only: %i[show update create destroy] do+ resources :posts, only: %i[show update create destroy], defaults: { format: "json" } dodelete "bookmark", to: "posts#destroy_bookmark"put "wiki"put "post_type"diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rbindex d948d225e52..043a625b987 100644--- a/spec/requests/posts_controller_spec.rb+++ b/spec/requests/posts_controller_spec.rb@@ -642,6 +642,24 @@ RSpec.describe PostsController doexpect(post.topic.reload.category_id).not_to eq(category.id)end+ describe "trying to add a link without permission" do+ it "returns an error message if links are added to posts when not allowed" do+ post = create_post+ sign_in(post.user)+ SiteSetting.post_links_allowed_groups = Group::AUTO_GROUPS[:admins]++ put "/posts/#{post.id}",+ params: {+ post: {+ raw: "I'm editing this post to add www.linkhere.com",+ },+ }++ expect(response.status).to eq(422)+ expect(response.body).to include("Sorry, you can't include links in your posts.")+ end+ end+describe "with Post.plugin_permitted_update_params" dobefore doplugin = Plugin::Instance.new