aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/xml_serialization_test.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-12-20 11:23:07 -0300
committerEmilio Tagua <miloops@gmail.com>2010-12-20 11:23:07 -0300
commit02fc6fbccdd3345e95592cc14e7855e2f1ea14b3 (patch)
treeb26b91e2b2fad62ec382c9cee4ca2ac318f09257 /activerecord/test/cases/xml_serialization_test.rb
parent2ba06b48defaca940e7c878724e2fb1c090eaa92 (diff)
parent0cbfd6c28d327304432f7d0c067662b5c1e41a78 (diff)
downloadrails-02fc6fbccdd3345e95592cc14e7855e2f1ea14b3.tar.gz
rails-02fc6fbccdd3345e95592cc14e7855e2f1ea14b3.tar.bz2
rails-02fc6fbccdd3345e95592cc14e7855e2f1ea14b3.zip
Merge remote branch 'rails/master' into identity_map
Conflicts: activerecord/lib/active_record/associations/association_proxy.rb activerecord/lib/active_record/autosave_association.rb activerecord/lib/active_record/base.rb activerecord/lib/active_record/persistence.rb
Diffstat (limited to 'activerecord/test/cases/xml_serialization_test.rb')
-rw-r--r--activerecord/test/cases/xml_serialization_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb
index b11b340e94..a6074b23e7 100644
--- a/activerecord/test/cases/xml_serialization_test.rb
+++ b/activerecord/test/cases/xml_serialization_test.rb
@@ -4,6 +4,7 @@ require 'models/post'
require 'models/author'
require 'models/comment'
require 'models/company_in_module'
+require 'models/toy'
class XmlSerializationTest < ActiveRecord::TestCase
def test_should_serialize_default_root
@@ -83,6 +84,26 @@ class DefaultXmlSerializationTest < ActiveRecord::TestCase
end
end
+class DefaultXmlSerializationTimezoneTest < ActiveRecord::TestCase
+ def test_should_serialize_datetime_with_timezone
+ timezone, Time.zone = Time.zone, "Pacific Time (US & Canada)"
+
+ toy = Toy.create(:name => 'Mickey', :updated_at => Time.utc(2006, 8, 1))
+ assert_match %r{<updated-at type=\"datetime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
+ ensure
+ Time.zone = timezone
+ end
+
+ def test_should_serialize_datetime_with_timezone_reloaded
+ timezone, Time.zone = Time.zone, "Pacific Time (US & Canada)"
+
+ toy = Toy.create(:name => 'Minnie', :updated_at => Time.utc(2006, 8, 1)).reload
+ assert_match %r{<updated-at type=\"datetime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
+ ensure
+ Time.zone = timezone
+ end
+end
+
class NilXmlSerializationTest < ActiveRecord::TestCase
def setup
@xml = Contact.new.to_xml(:root => 'xml_contact')
@@ -241,4 +262,10 @@ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase
assert array.include? 'github'
end
+ def test_should_support_aliased_attributes
+ xml = Author.select("name as firstname").to_xml
+ array = Hash.from_xml(xml)['authors']
+ assert_equal array.size, array.select { |author| author.has_key? 'firstname' }.size
+ end
+
end