From c4cb2dd01410417b5ab027aff5d472d68d9cbdb1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 3 Dec 2007 01:47:21 +0000 Subject: Fixed that to_xml should not automatically pass :procs to associations included with :include (closes #10162) [chuyeow] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/xml_serialization_test.rb | 69 ++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 21 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb index 011f27ad14..9b74ddd45b 100644 --- a/activerecord/test/xml_serialization_test.rb +++ b/activerecord/test/xml_serialization_test.rb @@ -11,19 +11,19 @@ class XmlSerializationTest < Test::Unit::TestCase assert_match %r{^}, @xml assert_match %r{$}, @xml end - + def test_should_serialize_default_root_with_namespace @xml = Contact.new.to_xml :namespace=>"http://xml.rubyonrails.org/contact" assert_match %r{^}, @xml assert_match %r{$}, @xml end - + def test_should_serialize_custom_root @xml = Contact.new.to_xml :root => 'xml_contact' assert_match %r{^}, @xml assert_match %r{$}, @xml end - + def test_should_allow_undasherized_tags @xml = Contact.new.to_xml :root => 'xml_contact', :dasherize => false assert_match %r{^}, @xml @@ -48,25 +48,25 @@ class DefaultXmlSerializationTest < Test::Unit::TestCase def test_should_serialize_string assert_match %r{aaron stack}, @xml end - + def test_should_serialize_integer assert_match %r{25}, @xml end - + def test_should_serialize_binary assert_match %r{YmluYXJ5ZGF0YQ==\n}, @xml assert_match %r{2006-08-01T00:00:00Z}, @xml end - + def test_should_serialize_boolean assert_match %r{false}, @xml end - + def test_should_serialize_yaml assert_match %r{--- \n:gem: ruby\n}, @xml end @@ -80,14 +80,14 @@ class NilXmlSerializationTest < Test::Unit::TestCase def test_should_serialize_string assert_match %r{}, @xml end - + def test_should_serialize_integer assert %r{}.match(@xml) attributes = $1 assert_match %r{nil="true"}, attributes assert_match %r{type="integer"}, attributes end - + def test_should_serialize_binary assert %r{}.match(@xml) attributes = $1 @@ -95,21 +95,21 @@ class NilXmlSerializationTest < Test::Unit::TestCase assert_match %r{encoding="base64"}, attributes assert_match %r{nil="true"}, attributes end - + def test_should_serialize_datetime assert %r{}.match(@xml) attributes = $1 assert_match %r{nil="true"}, attributes assert_match %r{type="datetime"}, attributes end - + def test_should_serialize_boolean assert %r{}.match(@xml) attributes = $1 assert_match %r{type="boolean"}, attributes assert_match %r{nil="true"}, attributes end - + def test_should_serialize_yaml assert %r{}.match(@xml) attributes = $1 @@ -137,30 +137,57 @@ class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase assert_match %r{}, xml assert_match %r{}, xml end - + def test_methods_are_called_on_object xml = authors(:david).to_xml :methods => :label, :indent => 0 assert_match %r{}, xml end - + def test_should_not_call_methods_on_associations_that_dont_respond xml = authors(:david).to_xml :include=>:hello_posts, :methods => :label, :indent => 2 assert !authors(:david).hello_posts.first.respond_to?(:label) assert_match %r{^ }, xml assert_no_match %r{^