提交 dc3ac357 编写于 作者: M Marc-Andre Lafortune

Avoid using Integer#/, as it is redefined by the 'mathn' stdlib

上级 2f3d81c7
......@@ -129,7 +129,7 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options
minutes_with_offset = distance_in_minutes
end
remainder = (minutes_with_offset % 525600)
distance_in_years = (minutes_with_offset / 525600)
distance_in_years = (minutes_with_offset.div 525600)
if remainder < 131400
locale.t(:about_x_years, :count => distance_in_years)
elsif remainder < 394200
......
......@@ -19,6 +19,8 @@ def to_param
end
def assert_distance_of_time_in_words(from, to=nil)
Fixnum.send :private, :/ # test we avoid Integer#/ (redefined by mathn)
to ||= from
# 0..1 minute with :include_seconds => true
......@@ -121,6 +123,9 @@ def assert_distance_of_time_in_words(from, to=nil)
assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to)
assert_equal "less than 20 seconds", distance_of_time_in_words(from + 19.seconds, to, :include_seconds => true)
assert_equal "less than a minute", distance_of_time_in_words(from + 19.seconds, to, :include_seconds => false)
ensure
Fixnum.send :public, :/
end
def test_distance_in_words
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册