From 1aaf4490b29afc99cf19b18c4edbb1f28e6c37f5 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Thu, 30 Aug 2012 16:36:59 -0500 Subject: Add config.action_controller.permit_all_attributes to bypass StrongParameters protection --- .../test/controller/parameters/parameters_permit_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb index f143e22d2e..7fe8e6051b 100644 --- a/actionpack/test/controller/parameters/parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/parameters_permit_test.rb @@ -56,4 +56,18 @@ class ParametersPermitTest < ActiveSupport::TestCase @params.permit! assert_equal @params.permitted?, @params.dup.permitted? end + + test "permitted takes a default value when Parameters.permit_all_parameters is set" do + begin + ActionController::Parameters.permit_all_parameters = true + params = ActionController::Parameters.new({ person: { + age: "32", name: { first: "David", last: "Heinemeier Hansson" } + }}) + + assert params.slice(:person).permitted? + assert params[:person][:name].permitted? + ensure + ActionController::Parameters.permit_all_parameters = false + end + end end -- cgit v1.2.3