diff options
author | Marc Schütz <schuetzm@gmx.net> | 2013-07-06 11:59:30 +0200 |
---|---|---|
committer | Marc Schütz <schuetzm@gmx.net> | 2013-07-06 15:56:07 +0200 |
commit | 20c065594f1434c93e6fe64cad062a0df1f42a8e (patch) | |
tree | d56af1342f4e79dde5a1f2328ad2b429d6465e62 /activesupport/test | |
parent | 01d4941d0c87764742562c59d4bf7bb34ac108c4 (diff) | |
download | rails-20c065594f1434c93e6fe64cad062a0df1f42a8e.tar.gz rails-20c065594f1434c93e6fe64cad062a0df1f42a8e.tar.bz2 rails-20c065594f1434c93e6fe64cad062a0df1f42a8e.zip |
Make HashWithIndifferentAccess#select always return the hash.
Hash#select! returns nil if the hash didn't change and thus behaves differently
from select, so it's return value can't be used as result for the latter.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 0857796036..2d0c56bef5 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -487,6 +487,12 @@ class HashExtTest < ActiveSupport::TestCase assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash end + def test_indifferent_select_returns_a_hash_when_unchanged + hash = ActiveSupport::HashWithIndifferentAccess.new(@strings).select {|k,v| true} + + assert_instance_of ActiveSupport::HashWithIndifferentAccess, hash + end + def test_indifferent_select_bang indifferent_strings = ActiveSupport::HashWithIndifferentAccess.new(@strings) indifferent_strings.select! {|k,v| v == 1} |