aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/batches_test.rb10
-rw-r--r--activerecord/test/models/post.rb5
2 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index 3b4ff83725..4016f5f309 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -125,14 +125,18 @@ class EachTest < ActiveRecord::TestCase
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.first.title
+ start_title = title_order_posts.second.title
posts = []
- PostWithTitlePrimaryKey.find_in_batches(:batch_size => 1, :start => start_title) do |batch|
+ Post.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)
+ assert_equal title_order_posts[1..-1].map(&:id), posts.map(&:id)
+ ensure
+ Post.primary_key = old_primary_key
end
end
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 9858f68c4a..c995f59a15 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -186,8 +186,3 @@ class SpecialPostWithDefaultScope < ActiveRecord::Base
self.table_name = 'posts'
default_scope { where(:id => [1, 5,6]) }
end
-
-class PostWithTitlePrimaryKey < ActiveRecord::Base
- self.table_name = 'posts'
- self.primary_key = :title
-end