Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 1234

Show
Ignore:
Timestamp:
04/19/05 19:00:06 (3 years ago)
Author:
bitserf
Message:

Fix regression where nil values were incorrectly being cast into the
default values for their base types.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionwebservice/lib/action_web_service/casting.rb

    r1171 r1234  
    4040        def cast(value, signature_type) # :nodoc: 
    4141          return value if signature_type.nil? # signature.length != params.length 
     42          return nil if value.nil? 
    4243          unless signature_type.array? || signature_type.structured? 
    4344            return value if canonical_type(value.class) == signature_type.type 
  • trunk/actionwebservice/test/casting_test.rb

    r1072 r1234  
    6363  def test_array_type_casting 
    6464    assert_equal [1, 2, 3213992, 4], cast_expects(:int_array, ['1', '2', '3213992', '4'])[0] 
    65     assert_equal ['one', 'two', '5.0', '200', '', 'true'], cast_expects(:str_array, [:one, 'two', 5.0, 200, nil, true])[0] 
    66     assert_equal [true, false, true, true, false], cast_expects(:bool_array, ['1', nil, 'y', true, 'false'])[0] 
     65    assert_equal ['one', 'two', '5.0', '200', nil, 'true'], cast_expects(:str_array, [:one, 'two', 5.0, 200, nil, true])[0] 
     66    assert_equal [true, nil, true, true, false], cast_expects(:bool_array, ['1', nil, 'y', true, 'false'])[0] 
    6767  end 
    6868