diff options
author | John Maxwell <johnmaxwell@gmail.com> | 2009-07-22 20:47:15 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-07-22 20:47:15 -0500 |
commit | c39151a84768397d3bb025c6e8f877eac59ebbf9 (patch) | |
tree | a4e34e773ff2629abfab91925ed6cd3a2685408e /activerecord/test | |
parent | 9d7aae710384fb5f04129c35b86c5ea5fb9d83a9 (diff) | |
download | rails-c39151a84768397d3bb025c6e8f877eac59ebbf9.tar.gz rails-c39151a84768397d3bb025c6e8f877eac59ebbf9.tar.bz2 rails-c39151a84768397d3bb025c6e8f877eac59ebbf9.zip |
Patch to ActiveModel's (and ActiveRecord, by association) XML serialization: If two parameters are present in Procs supplied to to_xml's :procs option, the model being serialized will be passed as the second argument [#2373 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/xml_serialization_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb index b49997669e..e1ad5c1685 100644 --- a/activerecord/test/cases/xml_serialization_test.rb +++ b/activerecord/test/cases/xml_serialization_test.rb @@ -174,6 +174,12 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase assert_match %r{<nationality>Danish</nationality>}, xml end + def test_dual_arity_procs_are_called_on_object + proc = Proc.new { |options, record| options[:builder].tag!('name-reverse', record.name.reverse) } + xml = authors(:david).to_xml(:procs => [ proc ]) + assert_match %r{<name-reverse>divaD</name-reverse>}, xml + end + def test_top_level_procs_arent_applied_to_associations author_proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') } xml = authors(:david).to_xml(:procs => [ author_proc ], :include => :posts, :indent => 2) |