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

Changeset 4909

Show
Ignore:
Timestamp:
09/02/06 21:00:09 (2 years ago)
Author:
bitsweat
Message:

to_xml: the :methods option works on arrays of records. Closes #5845.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r4898 r4909  
    11*SVN* 
     2 
     3* to_xml: the :methods option works on arrays of records.  #5845 [Josh Starcher] 
    24 
    35* Deprecation: update docs. #5998 [jakob@mentalized.net, Kevin Clark] 
  • trunk/activerecord/lib/active_record/xml_serialization.rb

    r4862 r4909  
    161161 
    162162    def serializable_method_attributes 
    163       Array(options.delete(:methods)).collect { |name| MethodAttribute.new(name.to_s, @record) } 
     163      Array(options[:methods]).collect { |name| MethodAttribute.new(name.to_s, @record) } 
    164164    end 
    165165 
  • trunk/activerecord/test/base_test.rb

    r4819 r4909  
    13411341    assert xml.include?(%(<replies><reply>)) 
    13421342  end 
     1343 
     1344  def test_array_to_xml_including_methods 
     1345    xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :methods => [ :topic_id ]) 
     1346    assert xml.include?(%(<topic-id type="integer">#{topics(:first).topic_id}</topic-id>)) 
     1347    assert xml.include?(%(<topic-id type="integer">#{topics(:second).topic_id}</topic-id>)) 
     1348  end 
    13431349   
    13441350  def test_array_to_xml_including_has_one_association 
  • trunk/activerecord/test/fixtures/topic.rb

    r3941 r4909  
    1010  end 
    1111   
     12  # trivial method for testing Array#to_xml with :methods 
     13  def topic_id 
     14    id 
     15  end 
     16 
    1217  protected 
    1318    def default_written_on