Changeset 4895
- Timestamp:
- 09/01/06 16:09:18 (2 years ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/hash/conversions.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/hash_ext_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r4885 r4895 1 1 *SVN* 2 3 * Fix cases where empty xml nodes weren't being translated to nil in Hash.create_from_xml [Rick Olson] 4 5 <written-on type="date"></written-on> # => { :type => 'date' } # WRONG 6 <written-on type="date"></written-on> # => nil # RIGHT 2 7 3 8 * Tighten rescue clauses. #5985 [james@grayproductions.net] trunk/activesupport/lib/active_support/core_ext/hash/conversions.rb
r4616 r4895 102 102 end 103 103 else 104 value.empty? || value['nil'] == 'true'? nil : value.inject({}) do |h,(k,v)|104 (value.blank? || value['type'] || value['nil'] == 'true') ? nil : value.inject({}) do |h,(k,v)| 105 105 h[k] = typecast_xml_value(v) 106 106 h trunk/activesupport/test/core_ext/hash_ext_test.rb
r4616 r4895 335 335 :author_email_address => "david@loudthinking.com", 336 336 :parent_id => nil 337 }.stringify_keys 338 339 assert_equal expected_topic_hash, Hash.create_from_xml(topic_xml)["topic"] 340 end 341 342 def test_single_record_from_xml_with_nil_values 343 topic_xml = <<-EOT 344 <topic> 345 <title></title> 346 <id type="integer"></id> 347 <approved type="boolean"></approved> 348 <written-on type="date"></written-on> 349 <viewed-at type="datetime"></viewed-at> 350 <parent-id></parent-id> 351 </topic> 352 EOT 353 354 expected_topic_hash = { 355 :title => nil, 356 :id => nil, 357 :approved => nil, 358 :written_on => nil, 359 :viewed_at => nil, 360 :parent_id => nil 337 361 }.stringify_keys 338 362