aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/numeric_ext_test.rb
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-05-30 02:29:17 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-05-30 02:47:56 -0700
commitf1eddea1e3f6faf93581c43651348f48b2b7d8bb (patch)
tree32d168a6e37f1b40d0eedfedf78ad93705cdab95 /activesupport/test/core_ext/numeric_ext_test.rb
parent58d3e025793bec3a97c6f3afd8d3e36040d21167 (diff)
downloadrails-f1eddea1e3f6faf93581c43651348f48b2b7d8bb.tar.gz
rails-f1eddea1e3f6faf93581c43651348f48b2b7d8bb.tar.bz2
rails-f1eddea1e3f6faf93581c43651348f48b2b7d8bb.zip
:scissors: removed deprecated `Numeric#ago` and friends
Replacements: 5.ago => 5.seconds.ago 5.until => 5.seconds.until 5.since => 5.seconds.since 5.from_now => 5.seconds.from_now The removed tests does not affect coverage – we have equivalent test cases in the tests for `AS::Duration`. See #12389 for the history and rationale behind this.
Diffstat (limited to 'activesupport/test/core_ext/numeric_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/numeric_ext_test.rb44
1 files changed, 1 insertions, 43 deletions
diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb
index 3b1dabea8d..dbc3ffd319 100644
--- a/activesupport/test/core_ext/numeric_ext_test.rb
+++ b/activesupport/test/core_ext/numeric_ext_test.rb
@@ -22,18 +22,6 @@ class NumericExtTimeAndDateTimeTest < ActiveSupport::TestCase
end
end
- def test_deprecated_since_and_ago
- assert_equal @now + 1, assert_deprecated { 1.since(@now) }
- assert_equal @now - 1, assert_deprecated { 1.ago(@now) }
- end
-
- def test_deprecated_since_and_ago_without_argument
- now = Time.now
- assert assert_deprecated { 1.since } >= now + 1
- now = Time.now
- assert assert_deprecated { 1.ago } >= now - 1
- end
-
def test_irregular_durations
assert_equal @now.advance(:days => 3000), 3000.days.since(@now)
assert_equal @now.advance(:months => 1), 1.month.since(@now)
@@ -84,36 +72,6 @@ class NumericExtTimeAndDateTimeTest < ActiveSupport::TestCase
assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10) + 1.year
end
- def test_since_and_ago_anchored_to_time_now_when_time_zone_is_not_set
- Time.zone = nil
- with_env_tz 'US/Eastern' do
- Time.stubs(:now).returns Time.local(2000)
- # since
- assert_not_instance_of ActiveSupport::TimeWithZone, assert_deprecated { 5.since }
- assert_equal Time.local(2000,1,1,0,0,5), assert_deprecated { 5.since }
- # ago
- assert_not_instance_of ActiveSupport::TimeWithZone, assert_deprecated { 5.ago }
- assert_equal Time.local(1999,12,31,23,59,55), assert_deprecated { 5.ago }
- end
- end
-
- def test_since_and_ago_anchored_to_time_zone_now_when_time_zone_is_set
- Time.zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
- with_env_tz 'US/Eastern' do
- Time.stubs(:now).returns Time.local(2000)
- # since
- assert_instance_of ActiveSupport::TimeWithZone, assert_deprecated { 5.since }
- assert_equal Time.utc(2000,1,1,0,0,5), assert_deprecated { 5.since.time }
- assert_equal 'Eastern Time (US & Canada)', assert_deprecated { 5.since.time_zone.name }
- # ago
- assert_instance_of ActiveSupport::TimeWithZone, assert_deprecated { 5.ago }
- assert_equal Time.utc(1999,12,31,23,59,55), assert_deprecated { 5.ago.time }
- assert_equal 'Eastern Time (US & Canada)', assert_deprecated { 5.ago.time_zone.name }
- end
- ensure
- Time.zone = nil
- end
-
protected
def with_env_tz(new_tz = 'US/Eastern')
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
@@ -435,7 +393,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase
assert_equal BigDecimal, BigDecimal("1000010").class
assert_equal '1 Million', BigDecimal("1000010").to_s(:human)
end
-
+
def test_in_milliseconds
assert_equal 10_000, 10.seconds.in_milliseconds
end