Skip to content
Browse files

load expects a Hash

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5008 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent b445ab9 commit 26b76ea4ce6837a158d99b1071f6ae408cf65854 @jeremy jeremy committed
Showing with 4 additions and 5 deletions.
  1. +1 −1 activeresource/lib/active_resource/base.rb
  2. +3 −4 activeresource/test/base/load_test.rb
View
2 activeresource/lib/active_resource/base.rb
@@ -134,7 +134,7 @@ def reload
# 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
View
7 activeresource/test/base/load_test.rb
@@ -14,10 +14,9 @@ def setup
@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

0 comments on commit 26b76ea

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