aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/batches_test.rb
diff options
context:
space:
mode:
authorAlexander Balashov <divineforest@gmail.com>2013-05-21 12:26:13 +0400
committerAlexander Balashov <divineforest@gmail.com>2013-05-21 12:26:13 +0400
commit4a4a566b122e8bf080d0b9c5964ae46d523c9dc6 (patch)
tree345037ac9571c03bc0ee8999074bdbc6d7e6fa96 /activerecord/test/cases/batches_test.rb
parentbff89a2022aedec60929f6d6744eefc84a5c102a (diff)
downloadrails-4a4a566b122e8bf080d0b9c5964ae46d523c9dc6.tar.gz
rails-4a4a566b122e8bf080d0b9c5964ae46d523c9dc6.tar.bz2
rails-4a4a566b122e8bf080d0b9c5964ae46d523c9dc6.zip
In batches test @total was assigned but not used. Use it in tests instead of Post.count
Diffstat (limited to 'activerecord/test/cases/batches_test.rb')
-rw-r--r--activerecord/test/cases/batches_test.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index ba6b0b1362..e09fa95756 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -12,7 +12,7 @@ class EachTest < ActiveRecord::TestCase
end
def test_each_should_execute_one_query_per_batch
- assert_queries(Post.count + 1) do
+ assert_queries(@total + 1) do
Post.find_each(:batch_size => 1) do |post|
assert_kind_of Post, post
end
@@ -51,7 +51,7 @@ class EachTest < ActiveRecord::TestCase
end
def test_find_in_batches_should_return_batches
- assert_queries(Post.count + 1) do
+ assert_queries(@total + 1) do
Post.find_in_batches(:batch_size => 1) do |batch|
assert_kind_of Array, batch
assert_kind_of Post, batch.first
@@ -60,7 +60,7 @@ class EachTest < ActiveRecord::TestCase
end
def test_find_in_batches_should_start_from_the_start_option
- assert_queries(Post.count) do
+ assert_queries(@total) do
Post.find_in_batches(:batch_size => 1, :start => 2) do |batch|
assert_kind_of Array, batch
assert_kind_of Post, batch.first
@@ -69,14 +69,12 @@ class EachTest < ActiveRecord::TestCase
end
def test_find_in_batches_shouldnt_execute_query_unless_needed
- post_count = Post.count
-
assert_queries(2) do
- Post.find_in_batches(:batch_size => post_count) {|batch| assert_kind_of Array, batch }
+ Post.find_in_batches(:batch_size => @total) {|batch| assert_kind_of Array, batch }
end
assert_queries(1) do
- Post.find_in_batches(:batch_size => post_count + 1) {|batch| assert_kind_of Array, batch }
+ Post.find_in_batches(:batch_size => @total + 1) {|batch| assert_kind_of Array, batch }
end
end