From 3436fdfc12d58925e3d981e0afa61084ea34736c Mon Sep 17 00:00:00 2001 From: Diego Algorta Date: Sat, 15 May 2010 12:33:18 -0300 Subject: Fix for get_ids when including a belongs_to association on a has_many association [#2896 state:resolved] Signed-off-by: Pratik Naik --- activerecord/test/cases/associations/has_many_associations_test.rb | 4 ++++ activerecord/test/models/post.rb | 1 + 2 files changed, 5 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index b55b08bf9d..6e47967696 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -900,6 +900,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert !company.clients.loaded? end + def test_get_ids_ignores_include_option + assert_equal [readers(:michael_welcome).id], posts(:welcome).readers_with_person_ids + end + def test_get_ids_for_unloaded_finder_sql_associations_loads_them company = companies(:first_firm) assert !company.clients_using_sql.loaded? diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index d092c4bf09..dd06822cfd 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -69,6 +69,7 @@ class Post < ActiveRecord::Base has_many :authors, :through => :categorizations has_many :readers + has_many :readers_with_person, :include => :person, :class_name => "Reader" has_many :people, :through => :readers has_many :people_with_callbacks, :source=>:person, :through => :readers, :before_add => lambda {|owner, reader| log(:added, :before, reader.first_name) }, -- cgit v1.2.3