aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-26 12:40:40 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-26 12:40:40 -0700
commitf078f913b06f601427192d52a83b1c6a401f5166 (patch)
treeece0c6c0c6959edcba2e8fed61aea84dc8a7b60c /activesupport/test
parent6ac33f9e4b4dbfe34f9884d7b262a7ba2c3356e1 (diff)
parentf38e752bdf27668faf1125479f815832484c0a72 (diff)
downloadrails-f078f913b06f601427192d52a83b1c6a401f5166.tar.gz
rails-f078f913b06f601427192d52a83b1c6a401f5166.tar.bz2
rails-f078f913b06f601427192d52a83b1c6a401f5166.zip
Merge pull request #7971 from dgraham/hash-replace
Implement HashWithIndifferentAccess#replace so key? works correctly.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 7cfe7b0ea7..6746b58cd3 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -428,6 +428,18 @@ class HashExtTest < ActiveSupport::TestCase
assert_equal 2, hash['b']
end
+ def test_indifferent_replace
+ hash = HashWithIndifferentAccess.new
+ hash[:a] = 42
+
+ replaced = hash.replace(b: 12)
+
+ assert hash.key?('b')
+ assert !hash.key?(:a)
+ assert_equal 12, hash[:b]
+ assert_same hash, replaced
+ end
+
def test_indifferent_merging_with_block
hash = HashWithIndifferentAccess.new
hash[:a] = 1