提交 a6e5d29e 编写于 作者: T Tom Lea 提交者: gbuesing

Added deprecated warning messages to Float#months and Float#years deprications.

上级 d599b800
......@@ -4,11 +4,11 @@ module Float #: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
......
......@@ -66,20 +66,22 @@ def test_since_and_ago_with_fractional_weeks
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册