aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/batches_test.rb
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-09-21 19:42:14 -0300
committerAlexis Bernard <alexis@obloh.com>2012-11-08 17:26:47 +0100
commit9673735074626a8e3920cc90c0d1c2f18bfffc8e (patch)
treec93b018a8d0ff47cf3a0d791f9514510c19d31e0 /activerecord/test/cases/batches_test.rb
parente41d78ce221b2ca84cc260e20f3813eaace586b3 (diff)
downloadrails-9673735074626a8e3920cc90c0d1c2f18bfffc8e.tar.gz
rails-9673735074626a8e3920cc90c0d1c2f18bfffc8e.tar.bz2
rails-9673735074626a8e3920cc90c0d1c2f18bfffc8e.zip
start could be a string
Related to 761bc751d31c22e2c2fdae2b4cdd435b68b6d783 and eb876c4d07130f15be2cac7be968cc393f959c62 Conflicts: activerecord/lib/active_record/relation/batches.rb activerecord/test/cases/batches_test.rb
Diffstat (limited to 'activerecord/test/cases/batches_test.rb')
-rw-r--r--activerecord/test/cases/batches_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index 660098b9ad..392898d080 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -136,4 +136,19 @@ class EachTest < ActiveRecord::TestCase
assert_equal special_posts_ids, posts.map(&:id)
end
+ def test_find_in_batches_should_use_any_column_as_primary_key
+ old_primary_key = Post.primary_key
+ Post.primary_key = :title
+ title_order_posts = Post.order('title asc')
+ start_title = title_order_posts.second.title
+
+ posts = []
+ Post.find_in_batches(:batch_size => 1, :start => start_title) do |batch|
+ posts.concat(batch)
+ end
+
+ assert_equal title_order_posts[1..-1].map(&:id), posts.map(&:id)
+ ensure
+ Post.primary_key = old_primary_key
+ end
end