Skip to content

Commit

Permalink
Add NamedScope#find_each tests [#2201 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Mar 11, 2009
1 parent 0433348 commit 0b6f514
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion activerecord/test/cases/named_scope_test.rb
Expand Up @@ -15,7 +15,7 @@ def test_implements_enumerable
assert_equal Topic.find(:all), Topic.base
assert_equal Topic.find(:all), Topic.base.to_a
assert_equal Topic.find(:first), Topic.base.first
assert_equal Topic.find(:all), Topic.base.each { |i| i }
assert_equal Topic.find(:all), Topic.base.map { |i| i }
end

def test_found_items_are_cached
Expand Down Expand Up @@ -316,6 +316,20 @@ def test_chaining_should_use_latest_conditions_when_searching
def test_methods_invoked_within_scopes_should_respect_scope
assert_equal [], Topic.approved.by_rejected_ids.proxy_options[:conditions][:id]
end

def test_named_scopes_batch_finders
assert_equal 3, Topic.approved.count

assert_queries(4) do
Topic.approved.find_each(:batch_size => 1) {|t| assert t.approved? }
end

assert_queries(3) do
Topic.approved.find_in_batches(:batch_size => 2) do |group|
group.each {|t| assert t.approved? }
end
end
end
end

class DynamicScopeMatchTest < ActiveRecord::TestCase
Expand Down

0 comments on commit 0b6f514

Please sign in to comment.