diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-07-17 07:10:53 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-17 07:10:53 -0600 |
commit | 3bda7ff763c55d33d18318bb2b3ea5c295f34000 (patch) | |
tree | cb8c690084083b6aee4a70ad29c24c0050f88bed /activesupport/test | |
parent | fbade51248ea48db87703ba7418badbd3ed85e36 (diff) | |
parent | 404eceba8c8f0951407c2508567f6abefec76e4c (diff) | |
download | rails-3bda7ff763c55d33d18318bb2b3ea5c295f34000.tar.gz rails-3bda7ff763c55d33d18318bb2b3ea5c295f34000.tar.bz2 rails-3bda7ff763c55d33d18318bb2b3ea5c295f34000.zip |
Merge pull request #28077 from Erol/make-reverse-merge-bang-order-consistent
Make the order of Hash#reverse_merge! consistent with HashWithIndifferentAccess
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index c537fb86fe..746d7ad416 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -302,9 +302,9 @@ class HashExtTest < ActiveSupport::TestCase end def test_reverse_merge - defaults = { a: "x", b: "y", c: 10 }.freeze + defaults = { d: 0, a: "x", b: "y", c: 10 }.freeze options = { a: 1, b: 2 } - expected = { a: 1, b: 2, c: 10 } + expected = { d: 0, a: 1, b: 2, c: 10 } # Should merge defaults into options, creating a new hash. assert_equal expected, options.reverse_merge(defaults) @@ -315,6 +315,9 @@ class HashExtTest < ActiveSupport::TestCase assert_equal expected, merged.reverse_merge!(defaults) assert_equal expected, merged + # Make the order consistent with the non-overwriting reverse merge. + assert_equal expected.keys, merged.keys + # Should be an alias for reverse_merge! merged = options.dup assert_equal expected, merged.reverse_update(defaults) |