diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-29 09:54:55 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-29 09:54:55 -0600 |
commit | ddb886ef1338e0e4fa84d6d8ba55161da34d91aa (patch) | |
tree | 7978a76a0c0db50f220402e05e9f799354068366 /activesupport/test/core_ext | |
parent | 90dbfdcba2110eb40f5c0c3a1d4c1d6ed46f5ab5 (diff) | |
parent | 6e574e8a11635ec4e579e5b247f6492b9bdc9279 (diff) | |
download | rails-ddb886ef1338e0e4fa84d6d8ba55161da34d91aa.tar.gz rails-ddb886ef1338e0e4fa84d6d8ba55161da34d91aa.tar.bz2 rails-ddb886ef1338e0e4fa84d6d8ba55161da34d91aa.zip |
Merge pull request #16357 from gchan/hwia-respects-to-hash-default
`HashWithIndifferentAccess.new` respects the default value or proc on
objects that respond to `#to_hash`
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 4624338df1..1d9b56b1b4 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -1044,6 +1044,24 @@ class HashExtTest < ActiveSupport::TestCase assert_nothing_raised { HashWithIndifferentAccess.new_from_hash_copying_default(hash) } end + + def test_new_with_to_hash_conversion_copies_default + normal_hash = Hash.new(3) + normal_hash[:a] = 1 + + hash = HashWithIndifferentAccess.new(HashByConversion.new(normal_hash)) + assert_equal 1, hash[:a] + assert_equal 3, hash[:b] + end + + def test_new_with_to_hash_conversion_copies_default_proc + normal_hash = Hash.new { 1 + 2 } + normal_hash[:a] = 1 + + hash = HashWithIndifferentAccess.new(HashByConversion.new(normal_hash)) + assert_equal 1, hash[:a] + assert_equal 3, hash[:b] + end end class IWriteMyOwnXML |