aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/xml_serialization_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-11-14 10:33:25 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-11-14 10:33:25 +0000
commitea256eaa7f189d069967f8efe3ca9177a5b57795 (patch)
treea4abcbc13a97542b043892ef14acaacea980e4f5 /activerecord/test/xml_serialization_test.rb
parenta75cafbda23e6381420d940058eddb1a8de54b5a (diff)
downloadrails-ea256eaa7f189d069967f8efe3ca9177a5b57795.tar.gz
rails-ea256eaa7f189d069967f8efe3ca9177a5b57795.tar.bz2
rails-ea256eaa7f189d069967f8efe3ca9177a5b57795.zip
Base#to_xml supports the nil="true" attribute like Hash#to_xml. Closes #8268.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8138 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/xml_serialization_test.rb')
-rw-r--r--activerecord/test/xml_serialization_test.rb30
1 files changed, 22 insertions, 8 deletions
diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb
index a5da55cd8d..011f27ad14 100644
--- a/activerecord/test/xml_serialization_test.rb
+++ b/activerecord/test/xml_serialization_test.rb
@@ -78,29 +78,43 @@ class NilXmlSerializationTest < Test::Unit::TestCase
end
def test_should_serialize_string
- assert_match %r{<name></name>}, @xml
+ assert_match %r{<name nil="true"></name>}, @xml
end
def test_should_serialize_integer
- assert_match %r{<age type="integer"></age>}, @xml
+ assert %r{<age (.*)></age>}.match(@xml)
+ attributes = $1
+ assert_match %r{nil="true"}, attributes
+ assert_match %r{type="integer"}, attributes
end
def test_should_serialize_binary
- assert_match %r{></avatar>}, @xml
- assert_match %r{<avatar(.*)(type="binary")}, @xml
- assert_match %r{<avatar(.*)(encoding="base64")}, @xml
+ assert %r{<avatar (.*)></avatar>}.match(@xml)
+ attributes = $1
+ assert_match %r{type="binary"}, attributes
+ assert_match %r{encoding="base64"}, attributes
+ assert_match %r{nil="true"}, attributes
end
def test_should_serialize_datetime
- assert_match %r{<created-at type=\"datetime\"></created-at>}, @xml
+ assert %r{<created-at (.*)></created-at>}.match(@xml)
+ attributes = $1
+ assert_match %r{nil="true"}, attributes
+ assert_match %r{type="datetime"}, attributes
end
def test_should_serialize_boolean
- assert_match %r{<awesome type=\"boolean\"></awesome>}, @xml
+ assert %r{<awesome (.*)></awesome>}.match(@xml)
+ attributes = $1
+ assert_match %r{type="boolean"}, attributes
+ assert_match %r{nil="true"}, attributes
end
def test_should_serialize_yaml
- assert_match %r{<preferences type=\"yaml\"></preferences>}, @xml
+ assert %r{<preferences(.*)></preferences>}.match(@xml)
+ attributes = $1
+ assert_match %r{type="yaml"}, attributes
+ assert_match %r{nil="true"}, attributes
end
end