From b6aa0e13b4e590b82550a6464924f431e57229df Mon Sep 17 00:00:00 2001 From: Joshua Bates Date: Thu, 17 Apr 2008 11:58:32 -0700 Subject: Fix include? on has_many collections with finder_sql to fall back to Array include? rather than try to use SQL. [#18 state:resolved] --- .../test/cases/associations/has_many_associations_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 6f0190e8d9..7b97afe42c 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -832,6 +832,17 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert ! firm.clients.loaded? end + def test_include_loads_collection_if_target_uses_finder_sql + firm = companies(:first_firm) + client = firm.clients_using_sql.first + + firm.reload + assert ! firm.clients_using_sql.loaded? + assert firm.clients_using_sql.include?(client) + assert firm.clients_using_sql.loaded? + end + + def test_include_returns_false_for_non_matching_record_to_verify_scoping firm = companies(:first_firm) client = Client.create!(:name => 'Not Associated') -- cgit v1.2.3