diff options
-rw-r--r-- | railties/test/application/configuration_test.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 95a2cc2d31..9fad1a4df6 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1130,6 +1130,7 @@ module ApplicationTests app "development" + ActionController::Base.object_id # force lazy load hooks to run assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters post "/posts", post: { "title" => "zomg" } @@ -1138,6 +1139,8 @@ module ApplicationTests test "config.action_controller.always_permitted_parameters are: controller, action by default" do app "development" + + ActionController::Base.object_id # force lazy load hooks to run assert_equal %w(controller action), ActionController::Parameters.always_permitted_parameters end @@ -1148,6 +1151,7 @@ module ApplicationTests app "development" + ActionController::Base.object_id # force lazy load hooks to run assert_equal %w( controller action format ), ActionController::Parameters.always_permitted_parameters end @@ -1170,6 +1174,7 @@ module ApplicationTests app "development" + ActionController::Base.object_id # force lazy load hooks to run assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters post "/posts", post: { "title" => "zomg" }, format: "json" @@ -1179,21 +1184,57 @@ module ApplicationTests test "config.action_controller.action_on_unpermitted_parameters is :log by default on development" do app "development" + ActionController::Base.object_id # force lazy load hooks to run assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters end test "config.action_controller.action_on_unpermitted_parameters is :log by default on test" do app "test" + ActionController::Base.object_id # force lazy load hooks to run assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters end test "config.action_controller.action_on_unpermitted_parameters is false by default on production" do app "production" + ActionController::Base.object_id # force lazy load hooks to run assert_equal false, ActionController::Parameters.action_on_unpermitted_parameters end + test "config.action_controller.permit_all_parameters can be configured in an initializer" do + app_file "config/initializers/permit_all_parameters.rb", <<-RUBY + Rails.application.config.action_controller.permit_all_parameters = true + RUBY + + app "development" + + ActionController::Base.object_id # force lazy load hooks to run + assert_equal true, ActionController::Parameters.permit_all_parameters + end + + test "config.action_controller.always_permitted_parameters can be configured in an initializer" do + app_file "config/initializers/always_permitted_parameters.rb", <<-RUBY + Rails.application.config.action_controller.always_permitted_parameters = [] + RUBY + + app "development" + + ActionController::Base.object_id # force lazy load hooks to run + assert_equal [], ActionController::Parameters.always_permitted_parameters + end + + test "config.action_controller.action_on_unpermitted_parameters can be configured in an initializer" do + app_file "config/initializers/action_on_unpermitted_parameters.rb", <<-RUBY + Rails.application.config.action_controller.action_on_unpermitted_parameters = :raise + RUBY + + app "development" + + ActionController::Base.object_id # force lazy load hooks to run + assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters + end + test "config.action_dispatch.ignore_accept_header" do make_basic_app do |application| application.config.action_dispatch.ignore_accept_header = true |