Permalink
Browse files

Fix regression where nil values were incorrectly being cast into the

default values for their base types.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1234 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 41bc063 commit 3cf461323c0401e56e4a7d7962745bbbe5316fd1 @leonbreedt leonbreedt committed Apr 19, 2005
Showing with 3 additions and 2 deletions.
  1. +1 −0 actionwebservice/lib/action_web_service/casting.rb
  2. +2 −2 actionwebservice/test/casting_test.rb
@@ -39,6 +39,7 @@ def cast_returns(api_method, return_value) # :nodoc:
def cast(value, signature_type) # :nodoc:
return value if signature_type.nil? # signature.length != params.length
+ return nil if value.nil?
unless signature_type.array? || signature_type.structured?
return value if canonical_type(value.class) == signature_type.type
end
@@ -62,8 +62,8 @@ def test_base_type_casting_invalid
def test_array_type_casting
assert_equal [1, 2, 3213992, 4], cast_expects(:int_array, ['1', '2', '3213992', '4'])[0]
- assert_equal ['one', 'two', '5.0', '200', '', 'true'], cast_expects(:str_array, [:one, 'two', 5.0, 200, nil, true])[0]
- assert_equal [true, false, true, true, false], cast_expects(:bool_array, ['1', nil, 'y', true, 'false'])[0]
+ assert_equal ['one', 'two', '5.0', '200', nil, 'true'], cast_expects(:str_array, [:one, 'two', 5.0, 200, nil, true])[0]
+ assert_equal [true, nil, true, true, false], cast_expects(:bool_array, ['1', nil, 'y', true, 'false'])[0]
end
def test_array_type_casting_failure

0 comments on commit 3cf4613

Please sign in to comment.