aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/xml_serialization_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2006-09-24 01:37:45 +0000
committerMichael Koziarski <michael@koziarski.com>2006-09-24 01:37:45 +0000
commit83d972e365963f44e4b1dd100a7c9c55a77e6d41 (patch)
treeeec5c65126e065f743b4c787795122ef135a43b5 /activerecord/test/xml_serialization_test.rb
parent8d809e724ac3e5ebc7f35e40f95632c853c68d89 (diff)
downloadrails-83d972e365963f44e4b1dd100a7c9c55a77e6d41.tar.gz
rails-83d972e365963f44e4b1dd100a7c9c55a77e6d41.tar.bz2
rails-83d972e365963f44e4b1dd100a7c9c55a77e6d41.zip
Duplicate the hash provided to AR::Base#to_xml to prevent unexpected side effects [Koz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5170 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/xml_serialization_test.rb')
-rw-r--r--activerecord/test/xml_serialization_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb
index 2fd9006821..73ff354c48 100644
--- a/activerecord/test/xml_serialization_test.rb
+++ b/activerecord/test/xml_serialization_test.rb
@@ -1,4 +1,6 @@
require 'abstract_unit'
+require 'fixtures/post'
+require 'fixtures/author'
class Contact < ActiveRecord::Base
# mock out self.columns so no pesky db is needed for these tests
@@ -107,4 +109,17 @@ class NilXmlSerializationTest < Test::Unit::TestCase
def test_should_serialize_boolean
assert_match %r{<awesome type=\"boolean\"></awesome>}, @xml
end
+end
+
+class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase
+ fixtures :authors, :posts
+ # to_xml used to mess with the hash the user provided which
+ # caused the builder to be reused
+ def test_passing_hash_shouldnt_reuse_builder
+ options = {:include=>:posts}
+ david = authors(:david)
+ first_xml_size = david.to_xml(options).size
+ second_xml_size = david.to_xml(options).size
+ assert_equal first_xml_size, second_xml_size
+ end
end \ No newline at end of file