aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash_ext_test.rb
diff options
context:
space:
mode:
authorErol Fornoles <erol.fornoles@gmail.com>2017-02-20 18:52:58 +0800
committerErol Fornoles <erol.fornoles@gmail.com>2017-03-06 15:32:01 +0800
commit7b633857ddcdb129d5b78f5d9e41994018115ed9 (patch)
treec9abbead4b4837251cdf5e3f91b03a800acd45cc /activesupport/test/core_ext/hash_ext_test.rb
parentd731d6366ae68c790ef79ff66b2d2d41f5767cc3 (diff)
downloadrails-7b633857ddcdb129d5b78f5d9e41994018115ed9.tar.gz
rails-7b633857ddcdb129d5b78f5d9e41994018115ed9.tar.bz2
rails-7b633857ddcdb129d5b78f5d9e41994018115ed9.zip
Make the order of Hash#reverse_merge! consistent with HashWithIndifferentAccess
Diffstat (limited to 'activesupport/test/core_ext/hash_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb7
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 525ea08abd..49a6800cf3 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -829,9 +829,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)
@@ -842,6 +842,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)