From 0d2c7ce554b404dd76a2c4d4733535d4ff844d52 Mon Sep 17 00:00:00 2001 From: Jarl Friis Date: Tue, 30 Apr 2013 19:56:19 +0200 Subject: [PATCH] Fix for running tests in non-Australian timezones --- spec/spec_helper.rb | 1 + .../extensions/multiparameter_handler_spec.rb | 2 +- spec/validates_timeliness/orm/active_record_spec.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 51c8e532..4afcd565 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -57,6 +57,7 @@ class PersonWithShim < Person include TestModelShim end +ActiveRecord::Base.default_timezone = :utc ActiveRecord::Base.time_zone_aware_attributes = true ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'}) ActiveRecord::Migration.verbose = false diff --git a/spec/validates_timeliness/extensions/multiparameter_handler_spec.rb b/spec/validates_timeliness/extensions/multiparameter_handler_spec.rb index 9c5ac99b..3a578c08 100644 --- a/spec/validates_timeliness/extensions/multiparameter_handler_spec.rb +++ b/spec/validates_timeliness/extensions/multiparameter_handler_spec.rb @@ -10,7 +10,7 @@ it 'should assign a Time value for valid datetimes' do employee = record_with_multiparameter_attribute(:birth_datetime, [2000, 2, 28, 12, 0, 0]) - employee.birth_datetime_before_type_cast.should eq Time.local(2000, 2, 28, 12, 0, 0) + employee.birth_datetime_before_type_cast.should eq Time.zone.local(2000, 2, 28, 12, 0, 0) end it 'should assign a string value for incomplete time' do diff --git a/spec/validates_timeliness/orm/active_record_spec.rb b/spec/validates_timeliness/orm/active_record_spec.rb index 73ac0a3c..531348de 100644 --- a/spec/validates_timeliness/orm/active_record_spec.rb +++ b/spec/validates_timeliness/orm/active_record_spec.rb @@ -221,7 +221,7 @@ class EmployeeWithParser < ActiveRecord::Base Employee.create(:birth_datetime => datetime) record = Employee.last - record.birth_datetime_before_type_cast.should match(/2010-01-01 00:00:00/) + record.birth_datetime_before_type_cast.should match(/#{datetime.utc.to_s[0...-4]}/) end context "with plugin parser" do