From 733499baab603a4e3a4d10155ba1398b5b220b1d Mon Sep 17 00:00:00 2001 From: Irina Dumitrascu Date: Sun, 27 Sep 2009 13:04:48 +0300 Subject: [PATCH] test for named scopes with find_each and associations (#3235) --- activerecord/test/cases/named_scope_test.rb | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index bb2aba9..7c17a6a 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -5,10 +5,11 @@ require 'models/topic' require 'models/comment' require 'models/reply' require 'models/author' +require 'models/person' require 'models/developer' class NamedScopeTest < ActiveRecord::TestCase - fixtures :posts, :authors, :topics, :comments, :author_addresses + fixtures :posts, :authors, :topics, :comments, :author_addresses, :people def test_implements_enumerable assert !Topic.find(:all).empty? @@ -369,6 +370,16 @@ class NamedScopeTest < ActiveRecord::TestCase end end + def test_named_scopes_batch_finders_with_associations + assert_equal 2, people(:david).agents.size # michael and susan + + Person.males.find_each do |person| + next unless person == people(:david) + + assert_equal 2, person.agents(true).size + end + end + def test_table_names_for_chaining_scopes_with_and_without_table_name_included assert_nothing_raised do Comment.for_first_post.for_first_author.all -- 1.6.3.3