aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-02-10 22:26:16 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-02-10 22:26:16 +0000
commit6608a3ef37a8f998958b867a1be186d33edbc151 (patch)
tree8adea40ad921d031718319c68d0460eb1498fa45 /activesupport/test
parent8ad5a29cef38cd95aac6553357fc32a6e9e7b411 (diff)
downloadrails-6608a3ef37a8f998958b867a1be186d33edbc151.tar.gz
rails-6608a3ef37a8f998958b867a1be186d33edbc151.tar.bz2
rails-6608a3ef37a8f998958b867a1be186d33edbc151.zip
Adding TimeWithZone #to_yaml, #to_datetime, #eql? and method aliases for duck-typing compatibility with Time
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8854 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index a286fda4e2..38646caa79 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -86,6 +86,10 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal "1999-12-31T19:00:00-05:00", @twz.xmlschema
end
+ def test_to_yaml
+ assert_equal "--- 1999-12-31 19:00:00 -05:00\n", @twz.to_yaml
+ end
+
def test_httpdate
assert_equal 'Sat, 01 Jan 2000 00:00:00 GMT', @twz.httpdate
end
@@ -111,6 +115,11 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal 0, @twz <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 0), TimeZone['UTC'] )
assert_equal(-1, @twz <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 1), TimeZone['UTC'] ))
end
+
+ def test_eql?
+ assert @twz.eql?(Time.utc(2000))
+ assert @twz.eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), TimeZone["Hawaii"]) )
+ end
def test_plus
assert_equal Time.utc(1999, 12, 31, 19, 0 ,5), (@twz + 5).time
@@ -158,6 +167,10 @@ uses_tzinfo 'TimeWithZoneTest' do
def test_to_time
assert_equal @twz, @twz.to_time
end
+
+ def test_to_datetime
+ assert_equal DateTime.civil(1999, 12, 31, 19, 0, 0, Rational(-18_000, 86_400)), @twz.to_datetime
+ end
def test_acts_like_time
assert @twz.acts_like?(:time)