From da9ed153f7ff95026f322a54f64d0b8795511226 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sat, 7 Jun 2014 07:14:37 -0600 Subject: Don't rely on `Time.current` in tests Millisecond inequality causes failures on Travis --- activerecord/test/cases/adapters/postgresql/array_test.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'activerecord/test/cases') 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 -- cgit v1.2.3