aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2012-11-14 16:37:28 -0500
committerMarc-Andre Lafortune <github@marc-andre.ca>2012-11-14 16:49:33 -0500
commitdc3ac357dc21c8ba05de95760da2b2c9f963012e (patch)
tree29dbce8aa752513aa417d1c0842a5966844bbd20 /actionpack
parent2f3d81c764a8b527299be8c33c64814431f83482 (diff)
downloadrails-dc3ac357dc21c8ba05de95760da2b2c9f963012e.tar.gz
rails-dc3ac357dc21c8ba05de95760da2b2c9f963012e.tar.bz2
rails-dc3ac357dc21c8ba05de95760da2b2c9f963012e.zip
Avoid using Integer#/, as it is redefined by the 'mathn' stdlib
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb2
-rw-r--r--actionpack/test/template/date_helper_test.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 459f95bb73..6e51ba66a5 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -129,7 +129,7 @@ module ActionView
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
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index 8bd8eff3c0..f9ce63fcb0 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -19,6 +19,8 @@ class DateHelperTest < ActionView::TestCase
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 @@ class DateHelperTest < ActionView::TestCase
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