Merge pull request #15557 from sgrif/sg-specify-time-zone

Specify a time zone when testing TZ aware attributes
This commit is contained in:
Matthew Draper 2014-06-08 01:03:06 +09:30
commit 2f5fab8d5a

@ -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 @@ def test_escaping
end
def test_datetime_with_timezone_awareness
with_timezone_config aware_attributes: true do
PgArray.reset_column_information
current_time = [Time.current]
tz = "Pacific Time (US & Canada)"
record = PgArray.new(datetimes: current_time)
assert_equal current_time, record.datetimes
in_time_zone tz do
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.reload
assert_equal current_time, record.datetimes
assert_equal [time], record.datetimes
end
end