aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/batches_test.rb
diff options
context:
space:
mode:
authorToshiyuki Kawanishi <toshi.kawanishi@gmail.com>2012-09-15 17:39:11 +0900
committerToshiyuki Kawanishi <toshi.kawanishi@gmail.com>2012-09-16 20:02:23 +0900
commit761bc751d31c22e2c2fdae2b4cdd435b68b6d783 (patch)
tree3be6eea9bbeef057a0ab55796e1e693e76af0226 /activerecord/test/cases/batches_test.rb
parent56c60cab563a1adf778e18c5c8d0935fac26b6b8 (diff)
downloadrails-761bc751d31c22e2c2fdae2b4cdd435b68b6d783.tar.gz
rails-761bc751d31c22e2c2fdae2b4cdd435b68b6d783.tar.bz2
rails-761bc751d31c22e2c2fdae2b4cdd435b68b6d783.zip
Fix find_in_batches with customized primary_key
Diffstat (limited to 'activerecord/test/cases/batches_test.rb')
-rw-r--r--activerecord/test/cases/batches_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index cdd4b49042..3b4ff83725 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -124,4 +124,15 @@ 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
+ title_order_posts = Post.order('title asc')
+ start_title = title_order_posts.first.title
+
+ posts = []
+ PostWithTitlePrimaryKey.find_in_batches(:batch_size => 1, :start => start_title) do |batch|
+ posts.concat(batch)
+ end
+
+ assert_equal title_order_posts.map(&:id), posts.map(&:id)
+ end
end