aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
authorPawel Pierzchala <pawel.pierzchala@llp.pl>2012-01-05 11:02:14 +0100
committerPawel Pierzchala <pawel.pierzchala@llp.pl>2012-01-05 13:23:13 +0100
commitc766f3e4b013cf4bcc4ad9ba64636bbf944b320c (patch)
treea3cf4069a0f6014b84cd8545446d61239d30c0e4 /activesupport/test/core_ext/time_ext_test.rb
parent78372b6cbb655227f4e6ddcb32187704659de84f (diff)
downloadrails-c766f3e4b013cf4bcc4ad9ba64636bbf944b320c.tar.gz
rails-c766f3e4b013cf4bcc4ad9ba64636bbf944b320c.tar.bz2
rails-c766f3e4b013cf4bcc4ad9ba64636bbf944b320c.zip
Nano seconds fraction of time is copied properly in Time#advance
When day, month or year was passed, advance created a new time ignoring previous nsec fraction. Now nsec is passed through usec as a Rational number.
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 6cc63851e9..1c22a79d75 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -491,6 +491,11 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.utc(2013,10,17,20,22,19), Time.utc(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5, :hours => 5, :minutes => 7, :seconds => 9)
end
+ def test_advance_with_nsec
+ t = Time.at(0, Rational(108635108, 1000))
+ assert_equal t, t.advance(:months => 0)
+ end
+
def test_prev_week
with_env_tz 'US/Eastern' do
assert_equal Time.local(2005,2,21), Time.local(2005,3,1,15,15,10).prev_week