diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-05-01 14:32:50 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-05-01 14:32:50 -0500 |
commit | e2af713d1c71b4f319e5435a63011a7bc23f77c3 (patch) | |
tree | 0397b4aea75e5c77eb6b288996769fbe24f65b60 /activerecord/test/cases/associations | |
parent | 9c20391bbe6ec1c56f8c8ed4aefb31a93576f76a (diff) | |
parent | 74436d2203eba186baebc1ddc82ff2202d0fc005 (diff) | |
download | rails-e2af713d1c71b4f319e5435a63011a7bc23f77c3.tar.gz rails-e2af713d1c71b4f319e5435a63011a7bc23f77c3.tar.bz2 rails-e2af713d1c71b4f319e5435a63011a7bc23f77c3.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 1a3017a22c..546ed80894 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -11,11 +11,14 @@ require 'models/owner' require 'models/pet' require 'models/reference' require 'models/job' +require 'models/subscriber' +require 'models/subscription' +require 'models/book' class EagerAssociationTest < ActiveRecord::TestCase fixtures :posts, :comments, :authors, :categories, :categories_posts, :companies, :accounts, :tags, :taggings, :people, :readers, - :owners, :pets, :author_favorites, :jobs, :references + :owners, :pets, :author_favorites, :jobs, :references, :subscribers, :subscriptions, :books def test_loading_with_one_association posts = Post.find(:all, :include => :comments) @@ -220,6 +223,24 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_no_queries{ assert_equal jobs(:unicyclist, :magician), michael.jobs.sort_by(&:id) } end + def test_eager_load_has_many_with_string_keys + subscriptions = subscriptions(:webster_awdr, :webster_rfr) + subscriber =Subscriber.find(subscribers(:second).id, :include => :subscriptions) + assert_equal subscriptions, subscriber.subscriptions.sort_by(&:id) + end + + def test_eager_load_has_many_through_with_string_keys + books = books(:awdr, :rfr) + subscriber = Subscriber.find(subscribers(:second).id, :include => :books) + assert_equal books, subscriber.books.sort_by(&:id) + end + + def test_eager_load_belongs_to_with_string_keys + subscriber = subscribers(:second) + subscription = Subscription.find(subscriptions(:webster_awdr).id, :include => :subscriber) + assert_equal subscriber, subscription.subscriber + end + def test_eager_association_loading_with_explicit_join posts = Post.find(:all, :include => :comments, :joins => "INNER JOIN authors ON posts.author_id = authors.id AND authors.name = 'Mary'", :limit => 1, :order => 'author_id') assert_equal 1, posts.length |