aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-12-16 15:31:34 -0500
committerSean Griffin <sean@seantheprogrammer.com>2015-12-16 13:33:22 -0700
commitbc39fa07ae20e119b9122625a10ed0e92e8839d0 (patch)
treedfed61b8e467612474b2721c8f68f471434ccded /activerecord/test/cases/base_test.rb
parentcbbb89f1c9edcf438625b10178c8b2faf6ef4114 (diff)
downloadrails-bc39fa07ae20e119b9122625a10ed0e92e8839d0.tar.gz
rails-bc39fa07ae20e119b9122625a10ed0e92e8839d0.tar.bz2
rails-bc39fa07ae20e119b9122625a10ed0e92e8839d0.zip
Fix test failures on Windows
Unlike unix, the TZ variable on Windows does not look at a database. It is always expected to be in the form {Standard Time Abbreviation}{UTC-Offset}{Daylight Time Abbriviation}. This changes the relevant tests to use the Windows form when run from Windows.
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rw-r--r--activerecord/test/cases/base_test.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index dc555caaff..d4d08049c8 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -211,7 +211,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_preserving_time_objects_with_local_time_conversion_to_default_timezone_utc
- with_env_tz 'America/New_York' do
+ with_env_tz eastern_time_zone do
with_timezone_config default: :utc do
time = Time.local(2000)
topic = Topic.create('written_on' => time)
@@ -224,7 +224,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_preserving_time_objects_with_time_with_zone_conversion_to_default_timezone_utc
- with_env_tz 'America/New_York' do
+ with_env_tz eastern_time_zone do
with_timezone_config default: :utc do
Time.use_zone 'Central Time (US & Canada)' do
time = Time.zone.local(2000)
@@ -239,7 +239,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_preserving_time_objects_with_utc_time_conversion_to_default_timezone_local
- with_env_tz 'America/New_York' do
+ with_env_tz eastern_time_zone do
with_timezone_config default: :local do
time = Time.utc(2000)
topic = Topic.create('written_on' => time)
@@ -252,7 +252,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_preserving_time_objects_with_time_with_zone_conversion_to_default_timezone_local
- with_env_tz 'America/New_York' do
+ with_env_tz eastern_time_zone do
with_timezone_config default: :local do
Time.use_zone 'Central Time (US & Canada)' do
time = Time.zone.local(2000)
@@ -266,6 +266,14 @@ class BasicsTest < ActiveRecord::TestCase
end
end
+ def eastern_time_zone
+ if Gem.win_platform?
+ "EST5EDT"
+ else
+ "America/New_York"
+ end
+ end
+
def test_custom_mutator
topic = Topic.find(1)
# This mutator is protected in the class definition