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

Changeset 6511

Show
Ignore:
Timestamp:
04/09/07 15:33:38 (1 year ago)
Author:
xal
Message:

Removed ill faded xml_node class from codebase. Use XmlSimple instead

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb

    r6081 r6511  
    11require 'cgi' 
    2 require 'action_controller/vendor/xml_node' 
    32require 'strscan' 
    43 
     
    5049        when Proc 
    5150          strategy.call(raw_post_data) 
    52         when :xml_simple 
     51        when :xml_simple, :xml_node 
    5352          raw_post_data.blank? ? {} : Hash.from_xml(raw_post_data) 
    5453        when :yaml 
    5554          YAML.load(raw_post_data) 
    56         when :xml_node 
    57           node = XmlNode.from_xml(raw_post_data) 
    58           { node.node_name => node } 
    5955      end 
    6056    rescue Exception => e # YAML, XML or Ruby code block errors 
  • trunk/actionpack/test/controller/webservice_test.rb

    r6401 r6511  
    4242    @controller = TestController.new 
    4343    ActionController::Base.param_parsers.clear 
    44     ActionController::Base.param_parsers[Mime::XML] = :xml_nod
     44    ActionController::Base.param_parsers[Mime::XML] = :xml_simpl
    4545  end 
    4646   
     
    5555    assert_equal 'entry', @controller.response.body 
    5656    assert @controller.params.has_key?(:entry) 
    57     assert_equal 'content...', @controller.params["entry"].summary.node_value 
     57    assert_equal 'content...', @controller.params["entry"]['summary'] 
    5858    assert_equal 'true', @controller.params["entry"]['attributed'] 
    5959  end 
     
    6464    assert_equal 'entry', @controller.response.body 
    6565    assert @controller.params.has_key?(:entry) 
    66     assert_equal 'content...', @controller.params["entry"].summary.node_value 
     66    assert_equal 'content...', @controller.params["entry"]['summary'] 
    6767    assert_equal 'true', @controller.params["entry"]['attributed'] 
    6868  end 
     
    184184     
    185185end 
    186  
    187  
    188 class XmlNodeTest < Test::Unit::TestCase 
    189   def test_all 
    190     xn = XmlNode.from_xml(%{<?xml version="1.0" encoding="UTF-8"?> 
    191       <response success='true'> 
    192       <page title='Ajax Summit' id='1133' email_address='ry87ib@backpackit.com'> 
    193         <description>With O'Reilly and Adaptive Path</description> 
    194         <notes> 
    195           <note title='Hotel' id='1020' created_at='2005-05-14 16:41:11'> 
    196             Staying at the Savoy 
    197           </note> 
    198         </notes> 
    199         <tags> 
    200           <tag name='Technology' id='4' /> 
    201           <tag name='Travel' id='5' /> 
    202         </tags> 
    203       </page> 
    204       </response> 
    205      } 
    206     )      
    207     assert_equal 'UTF-8', xn.node.document.encoding 
    208     assert_equal '1.0', xn.node.document.version 
    209     assert_equal 'true', xn['success'] 
    210     assert_equal 'response', xn.node_name 
    211     assert_equal 'Ajax Summit', xn.page['title'] 
    212     assert_equal '1133', xn.page['id'] 
    213     assert_equal "With O'Reilly and Adaptive Path", xn.page.description.node_value 
    214     assert_equal nil, xn.nonexistent 
    215     assert_equal "Staying at the Savoy", xn.page.notes.note.node_value.strip 
    216     assert_equal 'Technology', xn.page.tags.tag[0]['name'] 
    217     assert_equal 'Travel', xn.page.tags.tag[1][:name] 
    218     matches = xn.xpath('//@id').map{ |id| id.to_i } 
    219     assert_equal [4, 5, 1020, 1133], matches.sort 
    220     matches = xn.xpath('//tag').map{ |tag| tag['name'] } 
    221     assert_equal ['Technology', 'Travel'], matches.sort 
    222     assert_equal "Ajax Summit", xn.page['title'] 
    223     xn.page['title'] = 'Ajax Summit V2' 
    224     assert_equal "Ajax Summit V2", xn.page['title'] 
    225     assert_equal "Staying at the Savoy", xn.page.notes.note.node_value.strip 
    226     xn.page.notes.note.node_value = "Staying at the Ritz" 
    227     assert_equal "Staying at the Ritz", xn.page.notes.note.node_value.strip 
    228     assert_equal '5', xn.page.tags.tag[1][:id] 
    229     xn.page.tags.tag[1]['id'] = '7' 
    230     assert_equal '7', xn.page.tags.tag[1]['id'] 
    231   end 
    232    
    233  
    234   def test_small_entry 
    235     node = XmlNode.from_xml('<entry>hi</entry>') 
    236     assert_equal 'hi', node.node_value 
    237   end 
    238  
    239 end