aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/array_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-07 07:14:37 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-07 09:31:59 -0600
commitda9ed153f7ff95026f322a54f64d0b8795511226 (patch)
tree2d87ea4fdbc33513acc6340b1e8b9f672010c666 /activerecord/test/cases/adapters/postgresql/array_test.rb
parent23a751c2e15800c1b4aa96c10d1bfebc56fa30b9 (diff)
downloadrails-da9ed153f7ff95026f322a54f64d0b8795511226.tar.gz
rails-da9ed153f7ff95026f322a54f64d0b8795511226.tar.bz2
rails-da9ed153f7ff95026f322a54f64d0b8795511226.zip
Don't rely on `Time.current` in tests
Millisecond inequality causes failures on Travis
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/array_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/array_test.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/array_test.rb b/activerecord/test/cases/adapters/postgresql/array_test.rb
index 90b72563fa..c78c502478 100644
--- a/activerecord/test/cases/adapters/postgresql/array_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/array_test.rb
@@ -2,6 +2,8 @@
require "cases/helper"
class PostgresqlArrayTest < ActiveRecord::TestCase
+ include InTimeZone
+
class PgArray < ActiveRecord::Base
self.table_name = 'pg_arrays'
end
@@ -197,17 +199,20 @@ class PostgresqlArrayTest < ActiveRecord::TestCase
end
def test_datetime_with_timezone_awareness
- with_timezone_config aware_attributes: true do
+ tz = "Pacific Time (US & Canada)"
+
+ in_time_zone tz do
PgArray.reset_column_information
- current_time = [Time.current]
+ time_string = Time.current.to_s
+ time = Time.zone.parse(time_string)
- record = PgArray.new(datetimes: current_time)
- assert_equal current_time, record.datetimes
+ record = PgArray.new(datetimes: [time_string])
+ assert_equal [time], record.datetimes
record.save!
record.reload
- assert_equal current_time, record.datetimes
+ assert_equal [time], record.datetimes
end
end