From 7efcc5d72fb7e42358b4cb9b7f627e1a69c20911 Mon Sep 17 00:00:00 2001 From: itzki Date: Fri, 7 Dec 2012 04:30:00 +0900 Subject: Fix decorating columns for serialized attributes --- activerecord/test/cases/serialized_attribute_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb index 068f3cf3cd..6962da298e 100644 --- a/activerecord/test/cases/serialized_attribute_test.rb +++ b/activerecord/test/cases/serialized_attribute_test.rb @@ -212,4 +212,17 @@ class SerializedAttributeTest < ActiveRecord::TestCase assert_kind_of BCrypt::Password, topic.content assert_equal(true, topic.content == password, 'password should equal') end + + def test_serialize_attribute_via_select_method_when_time_zone_available + ActiveRecord::Base.time_zone_aware_attributes = true + Topic.serialize(:content, MyObject) + + myobj = MyObject.new('value1', 'value2') + topic = Topic.create(content: myobj) + + assert_equal(myobj, Topic.select(:content).find(topic.id).content) + assert_raise(ActiveModel::MissingAttributeError) { Topic.select(:id).find(topic.id).content } + ensure + ActiveRecord::Base.time_zone_aware_attributes = false + end end -- cgit v1.2.3