diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-26 22:53:07 +0000 |
---|---|---|
committer | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-26 23:17:56 +0000 |
commit | 7db1704068b86fb2212388b14b4963526bacfa5d (patch) | |
tree | 615165073929beb1f1c0ad67fd8f146446ac2c56 /activerecord/test/cases/associations | |
parent | f4f8923cf0ef5bd31f9e98cecf4603d0c4bde296 (diff) | |
download | rails-7db1704068b86fb2212388b14b4963526bacfa5d.tar.gz rails-7db1704068b86fb2212388b14b4963526bacfa5d.tar.bz2 rails-7db1704068b86fb2212388b14b4963526bacfa5d.zip |
Fix :include of has_many associations with :primary_key option
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index afbd9fddf9..ff3d6ece05 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -786,4 +786,21 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_equal Person.find(person.id).agents, person.agents end end + + def test_preload_has_many_using_primary_key + expected = Firm.find(:first).clients_using_primary_key.to_a + firm = Firm.find :first, :include => :clients_using_primary_key + assert_no_queries do + assert_equal expected, firm.clients_using_primary_key + end + end + + def test_include_has_many_using_primary_key + expected = Firm.find(1).clients_using_primary_key.sort_by &:name + firm = Firm.find 1, :include => :clients_using_primary_key, :order => 'clients_using_primary_keys_companies.name' + assert_no_queries do + assert_equal expected, firm.clients_using_primary_key + end + end + end |