Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Integer#div instead of Integer#/ to avoid side effects from mathn

  • Loading branch information...
commit 22edb664cf081485e4e37bf5a797890648126a79 1 parent 44f12bb
@marcandre marcandre authored
View
2  activesupport/lib/active_support/core_ext/array/grouping.rb
@@ -58,7 +58,7 @@ def in_groups(number, fill_with = nil)
# size / number gives minor group size;
# size % number gives how many objects need extra accommodation;
# each group hold either division or division + 1 items.
- division = size / number
+ division = size.div number
modulo = size % number
# create a new array avoiding dup
View
8 activesupport/test/core_ext/array_ext_test.rb
@@ -112,6 +112,14 @@ def test_to_s_db
end
class ArrayExtGroupingTests < ActiveSupport::TestCase
+ def setup
+ Fixnum.send :private, :/ # test we avoid Integer#/ (redefined by mathn)
+ end
+
+ def teardown
+ Fixnum.send :public, :/
+ end
+
def test_in_groups_of_with_perfect_fit
groups = []
('a'..'i').to_a.in_groups_of(3) do |group|
Please sign in to comment.
Something went wrong with that request. Please try again.