diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-31 07:50:15 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-31 07:50:15 +0000 |
commit | be827f9348a703b3048cb7728d0de6d019279bd9 (patch) | |
tree | 951f051662b7c26754fa31ea05dce255523014ee /activerecord/test/cases/associations | |
parent | e59978aa867ef07e16ad64f73f1ed5cafa98d0ea (diff) | |
download | rails-be827f9348a703b3048cb7728d0de6d019279bd9.tar.gz rails-be827f9348a703b3048cb7728d0de6d019279bd9.tar.bz2 rails-be827f9348a703b3048cb7728d0de6d019279bd9.zip |
Fixed preloading belongs_to associations which reference a custom foreign key. References #9640.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 9c258b574f..b606092d7e 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -7,10 +7,13 @@ require 'models/category' require 'models/company' require 'models/person' require 'models/reader' +require 'models/owner' +require 'models/pet' class EagerAssociationTest < ActiveRecord::TestCase fixtures :posts, :comments, :authors, :categories, :categories_posts, - :companies, :accounts, :tags, :taggings, :people, :readers + :companies, :accounts, :tags, :taggings, :people, :readers, + :owners, :pets def test_loading_with_one_association posts = Post.find(:all, :include => :comments) @@ -73,6 +76,11 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_nil Post.find(posts(:authorless).id, :include => :author).author end + def test_eager_association_loading_with_belongs_to_and_foreign_keys + pets = Pet.find(:all, :include => :owner) + assert_equal 3, pets.length + end + def test_eager_association_loading_with_belongs_to comments = Comment.find(:all, :include => :post) assert_equal 10, comments.length |