From 0980b78f4e21c069aad72cad2a93184bd4219739 Mon Sep 17 00:00:00 2001 From: Adam Groves Date: Wed, 10 Sep 2008 12:16:23 +0200 Subject: [PATCH] re-added to_xml --- activeresource/lib/active_resource/base.rb | 5 +++++ activeresource/test/base_test.rb | 8 ++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index d966062..9475263 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -854,6 +854,11 @@ module ActiveResource # # my_group.to_xml(:skip_instruct => true) # # => [...] + + def to_xml(options={}) + attributes.to_xml({:root => self.class.element_name}.merge(options)) + end + def encode(options={}) case self.class.format when ActiveResource::Formats[:xml] diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index 7460fd4..9d66ba3 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -825,6 +825,14 @@ class BaseTest < Test::Unit::TestCase def test_to_xml matz = Person.find(1) + xml = matz.to_xml + assert xml.starts_with?('') + assert xml.include?('Matz') + assert xml.include?('1') + end + + def test_encode + matz = Person.find(1) xml = matz.encode assert xml.starts_with?('') assert xml.include?('Matz') -- 1.5.4.4