aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/batches_test.rb
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2013-09-17 11:54:58 +0530
committerVipul A M <vipulnsward@gmail.com>2015-02-09 01:33:57 +0530
commit3dc432068b295504be938e7d4d67bc628edbf850 (patch)
tree2aa318996facf953d0605f92d7a73bc97e1a3e69 /activerecord/test/cases/batches_test.rb
parentde9a3748c436f849dd1877851115cd94663c2725 (diff)
downloadrails-3dc432068b295504be938e7d4d67bc628edbf850.tar.gz
rails-3dc432068b295504be938e7d4d67bc628edbf850.tar.bz2
rails-3dc432068b295504be938e7d4d67bc628edbf850.zip
Add an option `end_at` to `find_in_batches`
that complements the `start`parameter to specify where to stop batch processing
Diffstat (limited to 'activerecord/test/cases/batches_test.rb')
-rw-r--r--activerecord/test/cases/batches_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index c12fa03015..c05382598b 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -106,6 +106,15 @@ class EachTest < ActiveRecord::TestCase
end
end
+ def test_find_in_batches_should_end_at_the_end_option
+ assert_queries(6) do
+ Post.find_in_batches(batch_size: 1, end_at: 5) do |batch|
+ assert_kind_of Array, batch
+ assert_kind_of Post, batch.first
+ end
+ end
+ end
+
def test_find_in_batches_shouldnt_execute_query_unless_needed
assert_queries(2) do
Post.find_in_batches(:batch_size => @total) {|batch| assert_kind_of Array, batch }