aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorSimon Eskildsen <sirup@sirupsen.com>2015-07-10 03:10:45 +0000
committerSimon Eskildsen <sirup@sirupsen.com>2015-07-10 15:54:31 +0000
commit4ff255a6907cfa01e29fdc9b0f409082f3ee4259 (patch)
tree224f69b8b3fccb13ea4c00701be996238d80c7d7 /activesupport/test/core_ext
parent776e5991a9abf11818cb803e80976cea8b454c17 (diff)
downloadrails-4ff255a6907cfa01e29fdc9b0f409082f3ee4259.tar.gz
rails-4ff255a6907cfa01e29fdc9b0f409082f3ee4259.tar.bz2
rails-4ff255a6907cfa01e29fdc9b0f409082f3ee4259.zip
active_support/indifferent_hash: fix cloning default_proc on dup
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index e10bee5e00..137a03873e 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -998,6 +998,23 @@ class HashExtTest < ActiveSupport::TestCase
assert hash.key?('a')
assert_equal 1, hash[:a]
end
+
+ def test_dup_with_default_proc
+ hash = HashWithIndifferentAccess.new
+ hash.default_proc = proc { |h, v| raise "walrus" }
+ assert_nothing_raised { hash.dup }
+ end
+
+ def test_dup_with_default_proc_sets_proc
+ hash = HashWithIndifferentAccess.new
+ hash.default_proc = proc { |h, k| k + 1 }
+ new_hash = hash.dup
+
+ assert_equal 3, new_hash[2]
+
+ new_hash.default = 2
+ assert_equal 2, new_hash[:non_existant]
+ end
end
class IWriteMyOwnXML