diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-18 07:30:09 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-18 07:30:09 +0000 |
commit | 27ba5edef1c4264a8d1c0e54675723d37a391dd8 (patch) | |
tree | 83e5292708b2452b26d92f4a95dd6094f298c64e /activerecord/test/xml_serialization_test.rb | |
parent | 3202fbabe6df3591d7e2c35727ea9c8b68df8828 (diff) | |
download | rails-27ba5edef1c4264a8d1c0e54675723d37a391dd8.tar.gz rails-27ba5edef1c4264a8d1c0e54675723d37a391dd8.tar.bz2 rails-27ba5edef1c4264a8d1c0e54675723d37a391dd8.zip |
Hash#to_xml supports YAML attributes; ActiveRecord::Base#to_xml support serialized attributes. Closes #7502.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6444 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/xml_serialization_test.rb')
-rw-r--r-- | activerecord/test/xml_serialization_test.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb index 73ff354c48..61da81fe2d 100644 --- a/activerecord/test/xml_serialization_test.rb +++ b/activerecord/test/xml_serialization_test.rb @@ -9,11 +9,14 @@ class Contact < ActiveRecord::Base columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) end - column :name, :string - column :age, :integer - column :avatar, :binary - column :created_at, :datetime - column :awesome, :boolean + column :name, :string + column :age, :integer + column :avatar, :binary + column :created_at, :datetime + column :awesome, :boolean + column :preferences, :string + + serialize :preferences end class XmlSerializationTest < Test::Unit::TestCase @@ -57,7 +60,7 @@ end class DefaultXmlSerializationTest < Test::Unit::TestCase def setup - @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false).to_xml + @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml end def test_should_serialize_string @@ -81,6 +84,10 @@ class DefaultXmlSerializationTest < Test::Unit::TestCase def test_should_serialize_boolean assert_match %r{<awesome type=\"boolean\">false</awesome>}, @xml end + + def test_should_serialize_yaml + assert_match %r{<preferences type=\"yaml\">--- \n:gem: ruby\n</preferences>}, @xml + end end class NilXmlSerializationTest < Test::Unit::TestCase @@ -109,6 +116,10 @@ class NilXmlSerializationTest < Test::Unit::TestCase def test_should_serialize_boolean assert_match %r{<awesome type=\"boolean\"></awesome>}, @xml end + + def test_should_serialize_yaml + assert_match %r{<preferences type=\"yaml\"></preferences>}, @xml + end end class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase |