Permalink
Browse files

Merge pull request #8222 from marcandre/avoid_slash

Avoid using Integer#/, as it is redefined by the 'mathn' stdlib
  • Loading branch information...
2 parents bff4d8d + dc3ac35 commit f732f9b7b822c9806cf3e07f127d0771b815500b @rafaelfranca rafaelfranca committed Nov 15, 2012
@@ -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

0 comments on commit f732f9b

Please sign in to comment.