diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-26 23:26:37 +0000 |
---|---|---|
committer | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-26 23:26:37 +0000 |
commit | f9cab0e503a4721c9d0369f89bb85c6e658f778c (patch) | |
tree | 8d0c579bd0f75b824779b3a5ba76c3f39af157a6 /activerecord/test/cases/associations | |
parent | 7db1704068b86fb2212388b14b4963526bacfa5d (diff) | |
download | rails-f9cab0e503a4721c9d0369f89bb85c6e658f778c.tar.gz rails-f9cab0e503a4721c9d0369f89bb85c6e658f778c.tar.bz2 rails-f9cab0e503a4721c9d0369f89bb85c6e658f778c.zip |
Fix :include of has_one with :primary_key option
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index ff3d6ece05..14099d4176 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -803,4 +803,20 @@ class EagerAssociationTest < ActiveRecord::TestCase end end + def test_preload_has_one_using_primary_key + expected = Firm.find(:first).account_using_primary_key + firm = Firm.find :first, :include => :account_using_primary_key + assert_no_queries do + assert_equal expected, firm.account_using_primary_key + end + end + + def test_include_has_one_using_primary_key + expected = Firm.find(1).account_using_primary_key + firm = Firm.find(:all, :include => :account_using_primary_key, :order => 'accounts.id').detect {|f| f.id == 1} + assert_no_queries do + assert_equal expected, firm.account_using_primary_key + end + end + end |