diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-09-22 10:57:54 -0300 |
---|---|---|
committer | Alexis Bernard <alexis@obloh.com> | 2012-11-08 17:27:26 +0100 |
commit | 7031e365d6a8c00b62354f4abe8dff4802b38adf (patch) | |
tree | 366e1129a1a564a1420acf05dbdbcc51479b64df /activerecord | |
parent | 9673735074626a8e3920cc90c0d1c2f18bfffc8e (diff) | |
download | rails-7031e365d6a8c00b62354f4abe8dff4802b38adf.tar.gz rails-7031e365d6a8c00b62354f4abe8dff4802b38adf.tar.bz2 rails-7031e365d6a8c00b62354f4abe8dff4802b38adf.zip |
Fix test_find_in_batches_should_use_any_column_as_primary_key
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/batches_test.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb index 392898d080..16a93d97c6 100644 --- a/activerecord/test/cases/batches_test.rb +++ b/activerecord/test/cases/batches_test.rb @@ -1,8 +1,9 @@ require 'cases/helper' require 'models/post' +require 'models/subscriber' class EachTest < ActiveRecord::TestCase - fixtures :posts + fixtures :posts, :subscribers def setup @posts = Post.order("id asc") @@ -137,18 +138,14 @@ 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.second.title + nick_order_subscribers = Subscriber.order('nick asc') + start_nick = nick_order_subscribers.second.nick - posts = [] - Post.find_in_batches(:batch_size => 1, :start => start_title) do |batch| - posts.concat(batch) + subscribers = [] + Subscriber.find_in_batches(:batch_size => 1, :start => start_nick) do |batch| + subscribers.concat(batch) end - assert_equal title_order_posts[1..-1].map(&:id), posts.map(&:id) - ensure - Post.primary_key = old_primary_key + assert_equal nick_order_subscribers[1..-1].map(&:id), subscribers.map(&:id) end end |