aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/base_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-09 21:12:28 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-09 21:12:28 +0000
commitd872281975b2bdcfcd06e21b55d78c8fb53ba5d1 (patch)
tree8d380e62fc9df44a12d0132dfcdd58046c05ab8a /activerecord/test/base_test.rb
parent966c276d6071f8c331f75820f8c2f30d1bba02b2 (diff)
downloadrails-d872281975b2bdcfcd06e21b55d78c8fb53ba5d1.tar.gz
rails-d872281975b2bdcfcd06e21b55d78c8fb53ba5d1.tar.bz2
rails-d872281975b2bdcfcd06e21b55d78c8fb53ba5d1.zip
Fixed to_xml across the board to use nice indention, better skip_attributes workings, no type on strings, and cleaned tests [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3829 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/base_test.rb')
-rwxr-xr-xactiverecord/test/base_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index fe74bfa7e3..d82bde433d 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -1154,6 +1154,34 @@ class BasicsTest < Test::Unit::TestCase
assert_no_queries { assert true }
end
+ def test_to_xml
+ xml = Topic.find(:first).to_xml(:indent => 0, :skip_instruct => true)
+ assert_equal "<topic>", xml.first(7)
+ assert xml.include?(%(<title>The First Topic</title>))
+ assert xml.include?(%(<author-name>David</author-name>))
+ assert xml.include?(%(<id type="integer">1</id>))
+ assert xml.include?(%(<approved type="boolean">false</approved>))
+ assert xml.include?(%(<replies-count type="integer">0</replies-count>))
+ assert xml.include?(%(<bonus-time type="datetime">2000-01-01 08:28:00</bonus-time>))
+ assert xml.include?(%(<written-on type="datetime">2003-07-16 09:28:00</written-on>))
+ assert xml.include?(%(<content>Have a nice day</content>))
+ assert xml.include?(%(<author-email-address>david@loudthinking.com</author-email-address>))
+ assert xml.include?(%(<parent-id></parent-id>))
+ assert xml.include?(%(<last-read type="date">2004-04-15</last-read>))
+ end
+
+ def test_to_xml_skipping_attributes
+ xml = Topic.find(:first).to_xml(:indent => 0, :skip_instruct => true, :skip_attributes => :title)
+ breakpoint
+ assert_equal "<topic>", xml.first(7)
+ assert !xml.include?(%(<title>The First Topic</title>))
+ assert xml.include?(%(<author-name>David</author-name>))
+
+ xml = Topic.find(:first).to_xml(:indent => 0, :skip_instruct => true, :skip_attributes => [ :title, :author_name ])
+ assert !xml.include?(%(<title>The First Topic</title>))
+ assert !xml.include?(%(<author-name>David</author-name>))
+ end
+
# FIXME: this test ought to run, but it needs to run sandboxed so that it
# doesn't b0rk the current test environment by undefing everything.
#