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

Changeset 6540

Show
Ignore:
Timestamp:
04/19/07 22:32:39 (3 years ago)
Author:
david
Message:

Added yielding of builder in Hash#to_xml [DHH]

Files:

Legend:

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

    r6532 r6540  
    11*SVN* 
     2 
     3* Added yielding of builder in Hash#to_xml [DHH] 
    24 
    35* Hash#with_indifferent_access now also converts hashes kept in arrays to indifferent access (makes it easier to treat HTML and XML parameters the same) [DHH] 
  • trunk/activesupport/lib/active_support/core_ext/hash/conversions.rb

    r6532 r6540  
    100100              end 
    101101            end 
     102             
     103            yield options[:builder] if block_given? 
    102104          end 
    103105 
  • trunk/activesupport/test/core_ext/hash_ext_test.rb

    r6532 r6540  
    341341    assert xml.include?(%(<name>David</name>)) 
    342342    assert xml.include?(%(<age nil="true"></age>)) 
     343  end 
     344 
     345  def test_one_level_with_yielding 
     346    xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options) do |xml| 
     347      xml.creator("Rails") 
     348    end 
     349 
     350    assert_equal "<person>", xml.first(8) 
     351    assert xml.include?(%(<street>Paulina</street>)) 
     352    assert xml.include?(%(<name>David</name>)) 
     353    assert xml.include?(%(<creator>Rails</creator>)) 
    343354  end 
    344355