aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attribute_methods_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-03-26 11:47:20 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-03-26 11:50:31 -0700
commitdea3d2dd203fe2008ccfae6b6575da0b0001e466 (patch)
tree52d757983ce006853dc5a4fd80b916e31c98f44d /activerecord/test/cases/attribute_methods_test.rb
parentcb3e96a447df592947ae10221c7494eb8bf08012 (diff)
downloadrails-dea3d2dd203fe2008ccfae6b6575da0b0001e466.tar.gz
rails-dea3d2dd203fe2008ccfae6b6575da0b0001e466.tar.bz2
rails-dea3d2dd203fe2008ccfae6b6575da0b0001e466.zip
adding a test for attributes after type cast. thanks nragaz. :heart:
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index d03c3ee1a1..eacb18980c 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -132,6 +132,23 @@ class AttributeMethodsTest < ActiveRecord::TestCase
end
end
+ def test_read_attributes_after_type_cast_on_datetime
+ in_time_zone "Pacific Time (US & Canada)" do
+ record = @target.new
+
+ record.written_on = "2011-03-24"
+ assert_equal "2011-03-24", record.written_on_before_type_cast
+ assert_equal Time.zone.parse("2011-03-24"), record.written_on
+ assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"],
+ record.written_on.time_zone
+
+ record.save
+ record.reload
+
+ assert_equal Time.zone.parse("2011-03-24"), record.written_on
+ end
+ end
+
def test_hash_content
topic = Topic.new
topic.content = { "one" => 1, "two" => 2 }