mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix regression in Hash#dig
for HashWithIndifferentAccess.
This commit is contained in:
parent
538bce1f7c
commit
c918a3a069
3 changed files with 16 additions and 3 deletions
|
@ -1,3 +1,6 @@
|
|||
* Fix regression in `Hash#dig` for HashWithIndifferentAccess.
|
||||
*Jon Moss*
|
||||
|
||||
## Rails 5.0.0.beta2 (February 01, 2016) ##
|
||||
|
||||
* Change number_to_currency behavior for checking negativity.
|
||||
|
|
|
@ -69,9 +69,13 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
def default(*args)
|
||||
key = args.first
|
||||
args[0] = key.to_s if key.is_a?(Symbol)
|
||||
super(*args)
|
||||
arg_key = args.first
|
||||
|
||||
if include?(key = convert_key(arg_key))
|
||||
self[key]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.new_from_hash_copying_default(hash)
|
||||
|
|
|
@ -702,6 +702,12 @@ class HashExtTest < ActiveSupport::TestCase
|
|||
assert_equal h.class, h.dup.class
|
||||
end
|
||||
|
||||
def test_nested_dig_indifferent_access
|
||||
skip if RUBY_VERSION < "2.3.0"
|
||||
data = {"this" => {"views" => 1234}}.with_indifferent_access
|
||||
assert_equal 1234, data.dig(:this, :views)
|
||||
end
|
||||
|
||||
def test_assert_valid_keys
|
||||
assert_nothing_raised do
|
||||
{ :failure => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
|
||||
|
|
Loading…
Reference in a new issue