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 /activemodel/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 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/serializeration/xml_serialization_test.rb | 8 | ||||
-rw-r--r-- | activemodel/test/models/contact.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activemodel/test/cases/serializeration/xml_serialization_test.rb b/activemodel/test/cases/serializeration/xml_serialization_test.rb index ac8665d613..3ba826a8d0 100644 --- a/activemodel/test/cases/serializeration/xml_serialization_test.rb +++ b/activemodel/test/cases/serializeration/xml_serialization_test.rb @@ -95,6 +95,14 @@ class XmlSerializationTest < ActiveModel::TestCase assert_match %r{<awesome type=\"boolean\">false</awesome>}, @contact.to_xml end + test "should serialize array" do + assert_match %r{<social type=\"array\">\s*<social>twitter</social>\s*<social>github</social>\s*</social>}, @contact.to_xml(:methods => :social) + end + + test "should serialize hash" do + assert_match %r{<network>\s*<git type=\"symbol\">github</git>\s*</network>}, @contact.to_xml(:methods => :network) + end + test "should serialize yaml" do assert_match %r{<preferences type=\"yaml\">--- !ruby/object:OpenStruct \ntable:\s*:name: John\n</preferences>}, @contact.to_xml end diff --git a/activemodel/test/models/contact.rb b/activemodel/test/models/contact.rb index a9009fbdef..605e435f39 100644 --- a/activemodel/test/models/contact.rb +++ b/activemodel/test/models/contact.rb @@ -3,6 +3,14 @@ class Contact attr_accessor :id, :name, :age, :created_at, :awesome, :preferences + def social + %w(twitter github) + end + + def network + {:git => :github} + end + def initialize(options = {}) options.each { |name, value| send("#{name}=", value) } end |