diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-03-11 14:26:26 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-11 15:07:24 +0000 |
commit | 0b6f514947c38bf7af2b7e98905a49a94832e5f6 (patch) | |
tree | ab6b0b6499a73fa805ccba08bc0cd272e7f99f54 /activerecord/test/cases | |
parent | 04333482bd665e4d4ced167ff4f566ecfc0cc919 (diff) | |
download | rails-0b6f514947c38bf7af2b7e98905a49a94832e5f6.tar.gz rails-0b6f514947c38bf7af2b7e98905a49a94832e5f6.tar.bz2 rails-0b6f514947c38bf7af2b7e98905a49a94832e5f6.zip |
Add NamedScope#find_each tests [#2201 state:resolved]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/named_scope_test.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 4b2be0987e..a441a8f6e3 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -15,7 +15,7 @@ class NamedScopeTest < ActiveRecord::TestCase 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 @@ -316,6 +316,20 @@ class NamedScopeTest < ActiveRecord::TestCase 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 |