aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorBruce Krysiak <bruce@socialpl.us>2009-03-10 11:17:16 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-03-10 11:17:16 +0000
commit8272630ce8af0546e7d1aa9211a9d91b80700cbd (patch)
treebd1a2bda94fc7925480edfeefa003d22b5e5143a /activerecord/test
parent0c9bbf8c9dca46fbd7916640c417d13bf8b5af30 (diff)
downloadrails-8272630ce8af0546e7d1aa9211a9d91b80700cbd.tar.gz
rails-8272630ce8af0546e7d1aa9211a9d91b80700cbd.tar.bz2
rails-8272630ce8af0546e7d1aa9211a9d91b80700cbd.zip
Ensure ActiveRecord#to_xml respects :skip_types for included associations [#1632 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/xml_serialization_test.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/cases/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb
index 39c6ea820d..b49997669e 100644
--- a/activerecord/test/cases/xml_serialization_test.rb
+++ b/activerecord/test/cases/xml_serialization_test.rb
@@ -38,11 +38,15 @@ class XmlSerializationTest < ActiveRecord::TestCase
assert_match %r{<CreatedAt}, @xml
end
+ def test_should_allow_skipped_types
+ @xml = Contact.new(:age => 25).to_xml :skip_types => true
+ assert %r{<age>25</age>}.match(@xml)
+ end
+
def test_should_include_yielded_additions
@xml = Contact.new.to_xml do |xml|
xml.creator "David"
end
-
assert_match %r{<creator>David</creator>}, @xml
end
end
@@ -145,6 +149,13 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase
assert_match %r{<hello-post type="StiPost">}, xml
end
+ def test_included_associations_should_skip_types
+ xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0, :skip_types => true
+ assert_match %r{<hello-posts>}, xml
+ assert_match %r{<hello-post>}, xml
+ assert_match %r{<hello-post>}, xml
+ end
+
def test_methods_are_called_on_object
xml = authors(:david).to_xml :methods => :label, :indent => 0
assert_match %r{<label>.*</label>}, xml