aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-02-10 20:04:14 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-02-10 20:04:14 +0000
commit8831180b152007c52abb2a03bb351ebc7079c4c4 (patch)
treea210782b45b1b4612f1372118dd9ff71cc064b7d /activesupport/test/core_ext
parent163a4c6f4545c040c7ea25c298865a401b1b24f2 (diff)
downloadrails-8831180b152007c52abb2a03bb351ebc7079c4c4.tar.gz
rails-8831180b152007c52abb2a03bb351ebc7079c4c4.tar.bz2
rails-8831180b152007c52abb2a03bb351ebc7079c4c4.zip
Adding TimeWithZone #to_a, #to_f, #to_i, #httpdate, #rfc2822
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8852 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb24
1 files changed, 24 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 cc7a55b2ee..13ebfa644c 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -82,6 +82,14 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal "1999-12-31T19:00:00-05:00", @twz.xmlschema
end
+ def test_httpdate
+ assert_equal 'Sat, 01 Jan 2000 00:00:00 GMT', @twz.httpdate
+ end
+
+ def test_rfc2822
+ assert_equal "Fri, 31 Dec 1999 19:00:00 -0500", @twz.rfc2822
+ end
+
def test_compare_with_time
assert_equal 1, @twz <=> Time.utc(1999, 12, 31, 23, 59, 59)
assert_equal 0, @twz <=> Time.utc(2000, 1, 1, 0, 0, 0)
@@ -126,6 +134,22 @@ uses_tzinfo 'TimeWithZoneTest' do
twz2 = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2), TimeZone['UTC'] )
assert_equal 86_400.0, twz2 - twz1
end
+
+ def test_to_a
+ assert_equal [45, 30, 5, 1, 2, 2000, 2, 32, false, "HST"], ActiveSupport::TimeWithZone.new( Time.utc(2000, 2, 1, 15, 30, 45), TimeZone['Hawaii'] ).to_a
+ end
+
+ def test_to_f
+ result = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), TimeZone['Hawaii'] ).to_f
+ assert_equal 946684800.0, result
+ assert result.is_a?(Float)
+ end
+
+ def test_to_i
+ result = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), TimeZone['Hawaii'] ).to_i
+ assert_equal 946684800, result
+ assert result.is_a?(Integer)
+ end
def test_to_time
assert_equal @twz, @twz.to_time