mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't rely on Time.current
in tests
Millisecond inequality causes failures on Travis
This commit is contained in:
parent
23a751c2e1
commit
da9ed153f7
1 changed files with 11 additions and 6 deletions
|
@ -2,6 +2,8 @@
|
||||||
require "cases/helper"
|
require "cases/helper"
|
||||||
|
|
||||||
class PostgresqlArrayTest < ActiveRecord::TestCase
|
class PostgresqlArrayTest < ActiveRecord::TestCase
|
||||||
|
include InTimeZone
|
||||||
|
|
||||||
class PgArray < ActiveRecord::Base
|
class PgArray < ActiveRecord::Base
|
||||||
self.table_name = 'pg_arrays'
|
self.table_name = 'pg_arrays'
|
||||||
end
|
end
|
||||||
|
@ -197,17 +199,20 @@ class PostgresqlArrayTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_datetime_with_timezone_awareness
|
def test_datetime_with_timezone_awareness
|
||||||
with_timezone_config aware_attributes: true do
|
tz = "Pacific Time (US & Canada)"
|
||||||
PgArray.reset_column_information
|
|
||||||
current_time = [Time.current]
|
|
||||||
|
|
||||||
record = PgArray.new(datetimes: current_time)
|
in_time_zone tz do
|
||||||
assert_equal current_time, record.datetimes
|
PgArray.reset_column_information
|
||||||
|
time_string = Time.current.to_s
|
||||||
|
time = Time.zone.parse(time_string)
|
||||||
|
|
||||||
|
record = PgArray.new(datetimes: [time_string])
|
||||||
|
assert_equal [time], record.datetimes
|
||||||
|
|
||||||
record.save!
|
record.save!
|
||||||
record.reload
|
record.reload
|
||||||
|
|
||||||
assert_equal current_time, record.datetimes
|
assert_equal [time], record.datetimes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue