diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-15 18:28:10 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-15 18:28:10 +0000 |
commit | 31901a5939d5bfad8ae543724de8de3a069ab26a (patch) | |
tree | 6a19fe75bdc94866d4e6a2ebe884a056b160693e /activesupport | |
parent | 2aac6d90fe41ff5165fc4693baca9d668d79d0d8 (diff) | |
download | rails-31901a5939d5bfad8ae543724de8de3a069ab26a.tar.gz rails-31901a5939d5bfad8ae543724de8de3a069ab26a.tar.bz2 rails-31901a5939d5bfad8ae543724de8de3a069ab26a.zip |
Fixed errors thrown to namespace collision
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@421 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/core_ext/numeric/time.rb | 4 | ||||
-rw-r--r-- | activesupport/test/core_ext/numeric_ext_test.rb | 22 |
2 files changed, 20 insertions, 6 deletions
diff --git a/activesupport/lib/core_ext/numeric/time.rb b/activesupport/lib/core_ext/numeric/time.rb index 850dc9a783..ac5ecb8b70 100644 --- a/activesupport/lib/core_ext/numeric/time.rb +++ b/activesupport/lib/core_ext/numeric/time.rb @@ -38,7 +38,7 @@ module ActiveSupport alias :year :years # Reads best without arguments: 10.minutes.ago - def ago(time = Time.now) + def ago(time = ::Time.now) time - self end @@ -46,7 +46,7 @@ module ActiveSupport alias :until :ago # Reads best with argument: 10.minutes.since(time) - def since(time = Time.now) + def since(time = ::Time.now) time + self end diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index 6057c8f8c3..a83c472b84 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -13,17 +13,31 @@ class NumericExtTimeTest < Test::Unit::TestCase } end - def test_time_units + def test_units @seconds.each do |actual, expected| assert_equal expected, actual - assert_equal expected.since(@now), @now + actual - assert_equal expected.until(@now), @now - actual + end + end + + def test_intervals + @seconds.values.each do |seconds| + assert_equal seconds.since(@now), @now + seconds + assert_equal seconds.until(@now), @now - seconds + end + end + + # Test intervals based from Time.now + def test_now + @seconds.values.each do |seconds| + now = Time.now + assert seconds.ago >= now - seconds + now = Time.now + assert seconds.from_now >= now + seconds end end end class NumericExtSizeTest < Test::Unit::TestCase - def test_unit_in_terms_of_another relationships = { 1024.kilobytes => 1.megabyte, |