From e79193f852238816a9eeb26fbf1e94b369911718 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 15 Apr 2010 00:25:47 -0300 Subject: Test for unknown zone with nil utc_offset Signed-off-by: Jeremy Kemper --- activesupport/test/time_zone_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activesupport/test/time_zone_test.rb') diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index 68027f7c94..61c59060f3 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -274,6 +274,11 @@ class TimeZoneTest < Test::Unit::TestCase assert_raise(ArgumentError) { ActiveSupport::TimeZone[false] } end + def test_unknown_zone_shouldnt_have_tzinfo + zone = ActiveSupport::TimeZone.create("bogus") + assert_nil zone.tzinfo + end + def test_new assert_equal ActiveSupport::TimeZone["Central Time (US & Canada)"], ActiveSupport::TimeZone.new("Central Time (US & Canada)") end -- cgit v1.2.3 From a0cc94b32e5b4e4dce50787eed1208406f99ea82 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 15 Apr 2010 01:10:04 -0300 Subject: utc_offset returns nil for unknown zones Signed-off-by: Jeremy Kemper --- activesupport/test/time_zone_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activesupport/test/time_zone_test.rb') diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index 61c59060f3..58035ebbcd 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -274,9 +274,15 @@ class TimeZoneTest < Test::Unit::TestCase assert_raise(ArgumentError) { ActiveSupport::TimeZone[false] } end - def test_unknown_zone_shouldnt_have_tzinfo + def test_unknown_zone_shouldnt_have_tzinfo_nor_utc_offset zone = ActiveSupport::TimeZone.create("bogus") assert_nil zone.tzinfo + assert_nil zone.utc_offset + end + + def test_unknown_zone_with_utc_offset + zone = ActiveSupport::TimeZone.create("bogus", -21_600) + assert_equal -21_600, zone.utc_offset end def test_new -- cgit v1.2.3 From dadf35b2a9b0abb6421bc08f2fedba3dbe819d5e Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 16 Apr 2010 23:06:58 -0300 Subject: avoid warning: ambiguous first argument; put parentheses or even spaces --- activesupport/test/time_zone_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/test/time_zone_test.rb') diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index 58035ebbcd..3b7fbb7808 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -282,7 +282,7 @@ class TimeZoneTest < Test::Unit::TestCase def test_unknown_zone_with_utc_offset zone = ActiveSupport::TimeZone.create("bogus", -21_600) - assert_equal -21_600, zone.utc_offset + assert_equal(-21_600, zone.utc_offset) end def test_new -- cgit v1.2.3