Permalink
Browse files

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

Specify a time zone when testing TZ aware attributes
  • Loading branch information...
2 parents 16f595f + da9ed15 commit 2f5fab8d5af6dfe59e73fcf3d8d9902715b4284b @matthewd matthewd committed Jun 7, 2014
Showing with 10 additions and 5 deletions.
  1. +10 −5 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 @@ def test_escaping
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

0 comments on commit 2f5fab8

Please sign in to comment.