diff options
author | Eugene Kenny <elkenny@gmail.com> | 2017-07-04 22:13:29 +0100 |
---|---|---|
committer | Eugene Kenny <elkenny@gmail.com> | 2017-07-04 22:13:29 +0100 |
commit | 458a5502a17ccf58d5708a3b030ac9917a0a8476 (patch) | |
tree | a09ccadfc85ec545ca16dbaac9cb8ebb850c1dec /railties | |
parent | 9b3054384b3233c6be4284779010997ab7bc15b5 (diff) | |
download | rails-458a5502a17ccf58d5708a3b030ac9917a0a8476.tar.gz rails-458a5502a17ccf58d5708a3b030ac9917a0a8476.tar.bz2 rails-458a5502a17ccf58d5708a3b030ac9917a0a8476.zip |
Fix Parameters configuration integration tests
These tests relied on `ActionController::Parameters` being configured as
part of the boot process; since that now happens lazily we need to force
`ActionController::Base` to load so that we can test the behaviour.
The new tests added here ensure that `ActionController::Parameters` can
be configured from an initializer, which was broken until recently.
Diffstat (limited to 'railties')
-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 |