From 484253515c0e05760541dc48946361185c9e6904 Mon Sep 17 00:00:00 2001 From: Neer Friedman Date: Sun, 7 Jul 2013 17:38:09 +0300 Subject: Fix microsecond precision of Time#at_with_coercion When Time.at_with_coercion (wraps Time.at) is called with a single argument that "acts_like?(:time)" it is coerced to integer thus losing it's microsecond percision. This commits changes this to use `#to_f` to prevent the problem --- activesupport/test/core_ext/time_ext_test.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index d43cf41201..1681702bda 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -711,6 +711,10 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase end end + def test_at_with_time_microsecond_precision + assert_equal Time.at(Time.utc(2000, 1, 1, 0, 0, 0, 111)).to_f, Time.utc(2000, 1, 1, 0, 0, 0, 111).to_f + end + def test_eql? assert_equal true, Time.utc(2000).eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone['UTC']) ) assert_equal true, Time.utc(2000).eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone["Hawaii"]) ) -- cgit v1.2.3