diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-27 15:30:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 15:30:51 +0900 |
commit | 0d825a65e0cf9208d9c4ac1036bf361b847d89f6 (patch) | |
tree | 5bc3b552b58c2dd204d0a47f53d1cfacac248c74 /activesupport/test | |
parent | 801ccab22a8efc2611300a14a8b373a43aa0de28 (diff) | |
parent | de9e3238a008f8f20c5beedefb8787b6e51359d0 (diff) | |
download | rails-0d825a65e0cf9208d9c4ac1036bf361b847d89f6.tar.gz rails-0d825a65e0cf9208d9c4ac1036bf361b847d89f6.tar.bz2 rails-0d825a65e0cf9208d9c4ac1036bf361b847d89f6.zip |
Merge pull request #30728 from y-yagi/ensure_transform_keys_of_hwida_to_return_hwida
Ensure `HashWithIndifferentAccess#transform_keys` to return `HashWithIndifferentAccess`
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/hash_with_indifferent_access_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/hash_with_indifferent_access_test.rb b/activesupport/test/hash_with_indifferent_access_test.rb index b3788ee65c..b878ac20fa 100644 --- a/activesupport/test/hash_with_indifferent_access_test.rb +++ b/activesupport/test/hash_with_indifferent_access_test.rb @@ -399,6 +399,13 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase assert_instance_of ActiveSupport::HashWithIndifferentAccess, indifferent_strings end + def test_indifferent_transform_keys + hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).transform_keys { |k| k * 2 } + + assert_equal({ "aa" => 1, "bb" => 2 }, hash) + assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash + end + def test_indifferent_compact hash_contain_nil_value = @strings.merge("z" => nil) hash = ActiveSupport::HashWithIndifferentAccess.new(hash_contain_nil_value) |