diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-04-29 17:39:05 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-04-30 13:19:30 +0200 |
commit | 883f27aa9a6fae5194400bb8f00e343dcb610270 (patch) | |
tree | 3448209008959fdf955ccdbfa120599b7556c326 /activerecord/test | |
parent | 34908e4a666971216a92b58d8c62030b9a96b7ba (diff) | |
download | rails-883f27aa9a6fae5194400bb8f00e343dcb610270.tar.gz rails-883f27aa9a6fae5194400bb8f00e343dcb610270.tar.bz2 rails-883f27aa9a6fae5194400bb8f00e343dcb610270.zip |
test cases for record.to_xml [#458 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/xml_serialization_test.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/author.rb | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb index bd29ae2612..751946ffc5 100644 --- a/activerecord/test/cases/xml_serialization_test.rb +++ b/activerecord/test/cases/xml_serialization_test.rb @@ -234,4 +234,12 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase assert types.include?('StiPost') end + def test_should_produce_xml_for_methods_returning_array + xml = authors(:david).to_xml(:methods => :social) + array = Hash.from_xml(xml)['author']['social'] + assert_equal 2, array.size + assert array.include? 'twitter' + assert array.include? 'github' + end + end diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 025f6207f8..655b45bf57 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -104,6 +104,10 @@ class Author < ActiveRecord::Base "#{id}-#{name}" end + def social + %w(twitter github) + end + private def log_before_adding(object) @post_log << "before_adding#{object.id || '<new>'}" |