aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-08 15:06:11 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-08 15:06:11 -0700
commit65588b7463b227fd63f73b56b3df9d3ea5ab8996 (patch)
tree839346ee6b40dd1cd97f620c95094af1ffb1a711 /activerecord/test
parent42418cfc94d1356d35d28d786f63e7fab9406ad6 (diff)
downloadrails-65588b7463b227fd63f73b56b3df9d3ea5ab8996.tar.gz
rails-65588b7463b227fd63f73b56b3df9d3ea5ab8996.tar.bz2
rails-65588b7463b227fd63f73b56b3df9d3ea5ab8996.zip
Update test case for TZ aware attributes
The test added in 42418cfc94d1356d35d28d786f63e7fab9406ad6 wasn't actually testing anything, since the bug was with TZ aware attributes only.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/adapters/postgresql/infinity_test.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/infinity_test.rb b/activerecord/test/cases/adapters/postgresql/infinity_test.rb
index 30404cd181..74163ac712 100644
--- a/activerecord/test/cases/adapters/postgresql/infinity_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/infinity_test.rb
@@ -1,6 +1,8 @@
require "cases/helper"
class PostgresqlInfinityTest < ActiveRecord::TestCase
+ include InTimeZone
+
class PostgresqlInfinity < ActiveRecord::Base
end
@@ -42,9 +44,17 @@ class PostgresqlInfinityTest < ActiveRecord::TestCase
assert_equal Float::INFINITY, record.datetime
end
- test "assigning 'infinity' on a datetime column" do
- record = PostgresqlInfinity.create!(datetime: "infinity")
- assert_equal Float::INFINITY, record.datetime
- assert_equal record.datetime, record.reload.datetime
+ test "assigning 'infinity' on a datetime column with TZ aware attributes" do
+ begin
+ in_time_zone "Pacific Time (US & Canada)" do
+ record = PostgresqlInfinity.create!(datetime: "infinity")
+ assert_equal Float::INFINITY, record.datetime
+ assert_equal record.datetime, record.reload.datetime
+ end
+ ensure
+ # setting time_zone_aware_attributes causes the types to change.
+ # There is no way to do this automatically since it can be set on a superclass
+ PostgresqlInfinity.reset_column_information
+ end
end
end