diff options
author | Doug Cole <doug@estately.com> | 2013-10-26 19:22:31 -0700 |
---|---|---|
committer | Doug Cole <doug@estately.com> | 2013-10-26 19:22:31 -0700 |
commit | 7171111d3af10c80e3b38658d4fa0aa36858677f (patch) | |
tree | 13c78f5977c6a8cd39c930638f138f11afde6dee /actionpack/test | |
parent | 52199d1fd41ffc439357c16a7873fb04444175cd (diff) | |
download | rails-7171111d3af10c80e3b38658d4fa0aa36858677f.tar.gz rails-7171111d3af10c80e3b38658d4fa0aa36858677f.tar.bz2 rails-7171111d3af10c80e3b38658d4fa0aa36858677f.zip |
don't mutate hash with fetch
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/parameters/parameters_permit_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb index 84e007b5d0..b60c5f058d 100644 --- a/actionpack/test/controller/parameters/parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/parameters_permit_test.rb @@ -147,6 +147,12 @@ class ParametersPermitTest < ActiveSupport::TestCase assert_equal :foo, e.param end + test "fetch with a default value of a hash does not mutate the object" do + params = ActionController::Parameters.new({}) + params.fetch :foo, {} + assert_equal nil, params[:foo] + end + test "fetch doesnt raise ParameterMissing exception if there is a default" do assert_equal "monkey", @params.fetch(:foo, "monkey") assert_equal "monkey", @params.fetch(:foo) { "monkey" } |