diff options
author | Simon Eskildsen <sirup@sirupsen.com> | 2015-07-10 03:11:37 +0000 |
---|---|---|
committer | Simon Eskildsen <sirup@sirupsen.com> | 2015-07-10 15:54:37 +0000 |
commit | fa30dd6d2e3151ac2be16673d40cb458a76f1dbe (patch) | |
tree | eb7c4b36cb67a825c0c887de9213f07cc950dc7a /activesupport/test | |
parent | 4ff255a6907cfa01e29fdc9b0f409082f3ee4259 (diff) | |
download | rails-fa30dd6d2e3151ac2be16673d40cb458a76f1dbe.tar.gz rails-fa30dd6d2e3151ac2be16673d40cb458a76f1dbe.tar.bz2 rails-fa30dd6d2e3151ac2be16673d40cb458a76f1dbe.zip |
active_support/indifferent_hash: dont raise on to_hash when default_proc raises
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 137a03873e..6f66d70217 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -1015,6 +1015,20 @@ class HashExtTest < ActiveSupport::TestCase new_hash.default = 2 assert_equal 2, new_hash[:non_existant] end + + def test_to_hash_with_raising_default_proc + hash = HashWithIndifferentAccess.new + hash.default_proc = proc { |h, k| raise "walrus" } + + assert_nothing_raised { hash.to_hash } + end + + def test_new_from_hash_copying_default_should_not_raise_when_default_proc_does + hash = Hash.new + hash.default_proc = proc { |h, k| raise "walrus" } + + assert_nothing_raised { HashWithIndifferentAccess.new_from_hash_copying_default(hash) } + end end class IWriteMyOwnXML |