aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
authorstopdropandrew <andrew@kongregate.com>2013-02-24 13:07:20 -0800
committerstopdropandrew <andrew@kongregate.com>2013-02-24 13:24:50 -0800
commitcb100ca02bf0652e39a61e7687a6ac034b1a9c43 (patch)
treef06d115b43d7cd28e6e8c3c35d1dc298a71fc9c9 /activesupport/test/core_ext/time_with_zone_test.rb
parent1509844cdd53e137f8ae02d2df52d811357426ec (diff)
downloadrails-cb100ca02bf0652e39a61e7687a6ac034b1a9c43.tar.gz
rails-cb100ca02bf0652e39a61e7687a6ac034b1a9c43.tar.bz2
rails-cb100ca02bf0652e39a61e7687a6ac034b1a9c43.zip
Added `ActiveSupport::TimeWithZone#to_r` for `Time#at` compatibility.
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb11
1 files changed, 11 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 21fef88d79..0f5699fd63 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -326,6 +326,17 @@ class TimeWithZoneTest < ActiveSupport::TestCase
assert_equal 946684800, twz.to_i
end
+ def test_to_r
+ result = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Hawaii']).to_r
+ assert_equal Rational(946684800, 1), result
+ assert_kind_of Rational, result
+ end
+
+ def test_time_at
+ time = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Hawaii'])
+ assert_equal time, Time.at(time)
+ end
+
def test_to_time
with_env_tz 'US/Eastern' do
assert_equal Time, @twz.to_time.class