diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-01 00:28:40 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-01 00:28:40 +0000 |
commit | 0a2e980ddd3b69dcce51896b454f04e3a1d05ee9 (patch) | |
tree | 70d659a6a90888b041d3f548d19ef80f92ed1f10 /activerecord/test | |
parent | d950addbfd275a307382a23064a890c1385579dd (diff) | |
download | rails-0a2e980ddd3b69dcce51896b454f04e3a1d05ee9.tar.gz rails-0a2e980ddd3b69dcce51896b454f04e3a1d05ee9.tar.bz2 rails-0a2e980ddd3b69dcce51896b454f04e3a1d05ee9.zip |
Fix migration test when run in GMT zone. Closes #11477 [thechrisoshow]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9175 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 75c939f24f..eb6723bbf3 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -357,10 +357,16 @@ if ActiveRecord::Base.connection.supports_migrations? # Test DateTime column and defaults, including timezone. # FIXME: moment of truth may be Time on 64-bit platforms. if bob.moment_of_truth.is_a?(DateTime) - assert_equal DateTime.local_offset, bob.moment_of_truth.offset - assert_not_equal 0, bob.moment_of_truth.offset - assert_not_equal "Z", bob.moment_of_truth.zone - assert_equal DateTime::ITALY, bob.moment_of_truth.start + + with_env_tz 'US/Eastern' do + assert_equal DateTime.local_offset, bob.moment_of_truth.offset + assert_not_equal 0, bob.moment_of_truth.offset + assert_not_equal "Z", bob.moment_of_truth.zone + # US/Eastern is -5 hours from GMT + assert_equal Rational(-5, 24), bob.moment_of_truth.offset + assert_equal "-05:00", bob.moment_of_truth.zone + assert_equal DateTime::ITALY, bob.moment_of_truth.start + end end assert_equal TrueClass, bob.male?.class @@ -960,6 +966,15 @@ if ActiveRecord::Base.connection.supports_migrations? Person.connection.execute("select suitably_short_seq.nextval from dual") end end + + protected + def with_env_tz(new_tz = 'US/Eastern') + old_tz, ENV['TZ'] = ENV['TZ'], new_tz + yield + ensure + old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') + end + end uses_mocha 'Sexy migration tests' do |