File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -164,7 +164,8 @@ def convert_value(value)
164
164
if value . is_a? Hash
165
165
value . nested_under_indifferent_access
166
166
elsif value . is_a? ( Array )
167
- value . dup . replace ( value . map { |e | convert_value ( e ) } )
167
+ value = value . dup if value . frozen?
168
+ value . replace ( value . map { |e | convert_value ( e ) } )
168
169
else
169
170
value
170
171
end
Original file line number Diff line number Diff line change @@ -457,6 +457,13 @@ def test_indifferent_to_hash
457
457
assert_equal '1234' , roundtrip . default
458
458
end
459
459
460
+ def test_lookup_returns_the_same_object_that_is_stored_in_hash_indifferent_access
461
+ hash = HashWithIndifferentAccess . new { |h , k | h [ k ] = [ ] }
462
+ hash [ :a ] << 1
463
+
464
+ assert_equal [ 1 ] , hash [ :a ]
465
+ end
466
+
460
467
def test_indifferent_hash_with_array_of_hashes
461
468
hash = { "urls" => { "url" => [ { "address" => "1" } , { "address" => "2" } ] } } . with_indifferent_access
462
469
assert_equal "1" , hash [ :urls ] [ :url ] . first [ :address ]
You can’t perform that action at this time.
0 commit comments