Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Backport tests for subclassed arrays

  • Loading branch information...
commit 9bc338ed2f911d474fd126d2189eca080a93b590 1 parent 05da752
@lardawge lardawge authored jeremy committed
Showing with 14 additions and 0 deletions.
  1. +14 −0 activesupport/test/core_ext/hash_ext_test.rb
View
14 activesupport/test/core_ext/hash_ext_test.rb
@@ -262,6 +262,20 @@ def test_indifferent_hash_with_array_of_hashes
hash = { "urls" => { "url" => [ { "address" => "1" }, { "address" => "2" } ] }}.with_indifferent_access
assert_equal "1", hash[:urls][:url].first[:address]
end
+
+ def test_should_preserve_array_subclass_when_value_is_array
+ array = SubclassingArray.new
+ array << { "address" => "1" }
+ hash = { "urls" => { "url" => array }}.with_indifferent_access
+ assert_equal SubclassingArray, hash[:urls][:url].class
+ end
+
+ def test_should_preserve_array_class_when_hash_value_is_frozen_array
+ array = SubclassingArray.new
+ array << { "address" => "1" }
+ hash = { "urls" => { "url" => array.freeze }}.with_indifferent_access
+ assert_equal SubclassingArray, hash[:urls][:url].class
+ end
def test_stringify_and_symbolize_keys_on_indifferent_preserves_hash
h = HashWithIndifferentAccess.new
Please sign in to comment.
Something went wrong with that request. Please try again.