Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix loading of different elements in array then int and string [#5036

…state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 59693c4c49cce5e4cf53eb54e42e3da07a98467e 1 parent e1344bf
@jreidinger jreidinger authored josevalim committed
View
6 activeresource/lib/active_resource/base.rb
@@ -1222,10 +1222,10 @@ def load(attributes)
when Array
resource = find_or_create_resource_for_collection(key)
value.map do |attrs|
- if attrs.is_a?(String) || attrs.is_a?(Numeric)
- attrs.duplicable? ? attrs.dup : attrs
- else
+ if attrs.is_a?(Hash)
resource.new(attrs)
+ else
+ attrs.duplicable? ? attrs.dup : attrs
end
end
when Hash
View
12 activeresource/test/cases/base/load_test.rb
@@ -47,6 +47,8 @@ def setup
{ :id => 1, :name => 'Willamette' },
{ :id => 2, :name => 'Columbia', :rafted_by => @matz }],
:postal_codes => [ 97018, 1234567890 ],
+ :dates => [ Time.now ],
+ :votes => [ true, false, true ],
:places => [ "Columbia City", "Unknown" ]}}}
@person = Person.new
@@ -149,6 +151,16 @@ def test_recursively_loaded_collections
assert_kind_of Array, places
assert_kind_of String, places.first
assert_equal @deep[:street][:state][:places].first, places.first
+
+ dates = state.dates
+ assert_kind_of Array, dates
+ assert_kind_of Time, dates.first
+ assert_equal @deep[:street][:state][:dates].first, dates.first
+
+ votes = state.votes
+ assert_kind_of Array, votes
+ assert_kind_of TrueClass, votes.first
+ assert_equal @deep[:street][:state][:votes].first, votes.first
end
def test_nested_collections_within_the_same_namespace

0 comments on commit 59693c4

Please sign in to comment.
Something went wrong with that request. Please try again.