load expects a Hash
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5008 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
b445ab986a
commit
26b76ea4ce
|
@ -134,7 +134,7 @@ module ActiveResource
|
|||
# Manually load attributes from a hash. Recursively loads collections of
|
||||
# resources.
|
||||
def load(attributes)
|
||||
return self if attributes.nil?
|
||||
raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
|
||||
attributes.each do |key, value|
|
||||
@attributes[key.to_s] =
|
||||
case value
|
||||
|
|
|
@ -14,10 +14,9 @@ class BaseLoadTest < Test::Unit::TestCase
|
|||
@person = Person.new
|
||||
end
|
||||
|
||||
def test_load_nil
|
||||
assert_nothing_raised do
|
||||
assert_equal @person, @person.load(nil)
|
||||
end
|
||||
def test_load_expects_hash
|
||||
assert_raise(ArgumentError) { @person.load nil }
|
||||
assert_raise(ArgumentError) { @person.load '<person id="1"/>' }
|
||||
end
|
||||
|
||||
def test_load_simple_hash
|
||||
|
|
Loading…
Reference in New Issue