From cd1f2d7b0ed7a25ff1c298732f921ce6d6d86f73 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 27 Sep 2007 08:49:18 +0000 Subject: Date/Time/DateTime Ruby 1.9 compat git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7647 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/date_time_ext_test.rb | 1 + activesupport/test/core_ext/time_ext_test.rb | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index 3c79fccdd1..b7bdbc5deb 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -32,6 +32,7 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase assert_equal DateTime.new(2005, 2, 21), DateTime.new(2005, 2, 21).to_datetime end + # FIXME: ruby 1.9 compat def test_to_time assert_equal Time.utc(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12, 0, 0).to_time assert_equal Time.local(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24), 0).to_time diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 88fd16531e..4a64ebd584 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -279,7 +279,8 @@ class TimeExtCalculationsTest < Test::Unit::TestCase def test_to_s time = Time.utc(2005, 2, 21, 17, 44, 30) - assert_equal "Mon Feb 21 17:44:30 UTC 2005", time.to_s + assert_equal time.to_default_s, time.to_s + assert_equal time.to_default_s, time.to_s(:doesnt_exist) assert_equal "2005-02-21 17:44:30", time.to_s(:db) assert_equal "21 Feb 17:44", time.to_s(:short) assert_equal "17:44", time.to_s(:time) @@ -381,10 +382,10 @@ class TimeExtCalculationsTest < Test::Unit::TestCase end protected - def with_timezone new_tz='US/Eastern' + def with_timezone(new_tz = 'US/Eastern') old_tz, ENV['TZ'] = ENV['TZ'], new_tz yield ensure - ENV['TZ'] = old_tz + old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') end end -- cgit v1.2.3