aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorTom Lea <commit@tomlea.co.uk>2008-09-16 09:18:44 +0100
committergbuesing <gbuesing@gmail.com>2008-10-13 20:00:10 -0500
commita6e5d29e0839540b6b5a1a89bcb3b1d037120474 (patch)
tree3a7cca7cb5fa50abb3299a9139f516d8cd19fce7 /activesupport
parentd599b8000968047b4095dd8ff6c8ef10bb4ed462 (diff)
downloadrails-a6e5d29e0839540b6b5a1a89bcb3b1d037120474.tar.gz
rails-a6e5d29e0839540b6b5a1a89bcb3b1d037120474.tar.bz2
rails-a6e5d29e0839540b6b5a1a89bcb3b1d037120474.zip
Added deprecated warning messages to Float#months and Float#years deprications.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/float/time.rb4
-rw-r--r--activesupport/test/core_ext/duration_test.rb18
2 files changed, 12 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/core_ext/float/time.rb b/activesupport/lib/active_support/core_ext/float/time.rb
index 6229cfe76b..13f2e0ddca 100644
--- a/activesupport/lib/active_support/core_ext/float/time.rb
+++ b/activesupport/lib/active_support/core_ext/float/time.rb
@@ -4,11 +4,11 @@ module ActiveSupport #:nodoc:
module Time
# Deprication helper methods not available as core_ext is loaded first.
def years
- ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:years), caller)
+ ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:years, "Fractional years are not respected. Convert value to integer before calling #years."), caller)
years_without_deprecation
end
def months
- ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:months), "Fractional months are not respected. Use .to_i before ", caller)
+ ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:months, "Fractional months are not respected. Convert value to integer before calling #months."), caller)
months_without_deprecation
end
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb
index 7b767c819e..d1b15fd2ef 100644
--- a/activesupport/test/core_ext/duration_test.rb
+++ b/activesupport/test/core_ext/duration_test.rb
@@ -66,20 +66,22 @@ class DurationTest < Test::Unit::TestCase
end
def test_deprecated_fractional_years
- assert_deprecated{1.0.years}
- assert_deprecated{1.5.years}
+ years_re = /Fractional years are not respected\. Convert value to integer before calling #years\./
+ assert_deprecated(years_re){1.0.years}
+ assert_deprecated(years_re){1.5.years}
assert_not_deprecated{1.years}
- assert_deprecated{1.0.year}
- assert_deprecated{1.5.year}
+ assert_deprecated(years_re){1.0.year}
+ assert_deprecated(years_re){1.5.year}
assert_not_deprecated{1.year}
end
def test_deprecated_fractional_months
- assert_deprecated{1.5.months}
- assert_deprecated{1.0.months}
+ months_re = /Fractional months are not respected\. Convert value to integer before calling #months\./
+ assert_deprecated(months_re){1.5.months}
+ assert_deprecated(months_re){1.0.months}
assert_not_deprecated{1.months}
- assert_deprecated{1.5.month}
- assert_deprecated{1.0.month}
+ assert_deprecated(months_re){1.5.month}
+ assert_deprecated(months_re){1.0.month}
assert_not_deprecated{1.month}
end