aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2014-01-29 14:53:54 -0500
committerMarc-Andre Lafortune <github@marc-andre.ca>2014-02-05 16:49:29 -0500
commitd37f395be86d131d0218dadd189771f99b06874f (patch)
tree2e7e4fd9e918142725a263bc61f611a787b28e38 /activerecord/test
parent4499ab5fdeca46416cfc4a50a376eba4eb8e16b4 (diff)
downloadrails-d37f395be86d131d0218dadd189771f99b06874f.tar.gz
rails-d37f395be86d131d0218dadd189771f99b06874f.tar.bz2
rails-d37f395be86d131d0218dadd189771f99b06874f.zip
Return sized enumerator from Batches#find_in_batches
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/batches_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index 8216d74cb3..4ee09a640e 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -191,4 +191,14 @@ class EachTest < ActiveRecord::TestCase
end
end
end
+
+ if Enumerator.method_defined? :size
+ def test_find_in_batches_should_return_a_sized_enumerator
+ assert_equal 11, Post.find_in_batches(:batch_size => 1).size
+ assert_equal 6, Post.find_in_batches(:batch_size => 2).size
+ assert_equal 4, Post.find_in_batches(:batch_size => 2, :start => 4).size
+ assert_equal 4, Post.find_in_batches(:batch_size => 3).size
+ assert_equal 1, Post.find_in_batches(:batch_size => 10_000).size
+ end
+ end
end