1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

In batches test @total was assigned but not used. Use it in tests instead of Post.count

This commit is contained in:
Alexander Balashov 2013-05-21 12:26:13 +04:00
parent bff89a2022
commit 4a4a566b12

View file

@ -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