aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorPavel Evstigneev <pavel.evst@gmail.com>2016-10-11 21:29:20 +0800
committerRafael França <rafaelmfranca@gmail.com>2016-10-11 10:29:20 -0300
commitf80ddf30dd4cc5e66c2caf2ef8e10608b13e8493 (patch)
tree2913414946ca51184ed3d9955e9c06ccf5fb50ad /actionpack/test/controller
parentdae404473409fcab0e07976aec626df670e52282 (diff)
downloadrails-f80ddf30dd4cc5e66c2caf2ef8e10608b13e8493.tar.gz
rails-f80ddf30dd4cc5e66c2caf2ef8e10608b13e8493.tar.bz2
rails-f80ddf30dd4cc5e66c2caf2ef8e10608b13e8493.zip
ActionController::Parameters#deep_dup (#26567)
* ActionController::Parameters#deep_dup * Tests for ActionController::Parameters#deep_dup * Fix test for ActionController::Parameters#deep_dup * More tests for ActionController::Parameters#deep_dup [Rafael Mendonça França + Pavel Evstigneev]
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/parameters/dup_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/dup_test.rb b/actionpack/test/controller/parameters/dup_test.rb
index d88891ca30..fb707a1354 100644
--- a/actionpack/test/controller/parameters/dup_test.rb
+++ b/actionpack/test/controller/parameters/dup_test.rb
@@ -1,5 +1,6 @@
require "abstract_unit"
require "action_controller/metal/strong_parameters"
+require "active_support/core_ext/object/deep_dup"
class ParametersDupTest < ActiveSupport::TestCase
setup do
@@ -40,4 +41,25 @@ class ParametersDupTest < ActiveSupport::TestCase
dupped_params.permit!
assert_not_equal @params, dupped_params
end
+
+ test "deep_dup content" do
+ dupped_params = @params.deep_dup
+ dupped_params[:person][:age] = "45"
+ dupped_params[:person][:addresses].clear
+
+ assert_not_equal @params[:person][:age], dupped_params[:person][:age]
+ assert_not_equal @params[:person][:addresses], dupped_params[:person][:addresses]
+ end
+
+ test "deep_dup @permitted" do
+ dupped_params = @params.deep_dup
+ dupped_params.permit!
+
+ assert_not @params.permitted?
+ end
+
+ test "deep_dup @permitted is being copied" do
+ @params.permit!
+ assert @params.deep_dup.permitted?
+ end
end