Override #store to be consistent with #[].
[#5775 state:resolved] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
parent
621df2a1ec
commit
d80afed620
|
@ -45,6 +45,8 @@ module ActiveSupport
|
|||
regular_writer(convert_key(key), convert_value(value))
|
||||
end
|
||||
|
||||
alias_method :store, :[]=
|
||||
|
||||
# Updates the instantized hash with values from the second:
|
||||
#
|
||||
# hash_1 = HashWithIndifferentAccess.new
|
||||
|
|
|
@ -316,6 +316,16 @@ class HashExtTest < Test::Unit::TestCase
|
|||
assert_equal expected, hash_1
|
||||
end
|
||||
|
||||
def test_store_on_indifferent_access
|
||||
hash = HashWithIndifferentAccess.new
|
||||
hash.store(:test1, 1)
|
||||
hash.store('test1', 11)
|
||||
hash[:test2] = 2
|
||||
hash['test2'] = 22
|
||||
expected = { "test1" => 11, "test2" => 22 }
|
||||
assert_equal expected, hash
|
||||
end
|
||||
|
||||
def test_reverse_merge
|
||||
defaults = { :a => "x", :b => "y", :c => 10 }.freeze
|
||||
options = { :a => 1, :b => 2 }
|
||||
|
|
Loading…
Reference in New Issue