aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-03-24 14:46:17 +0000
committerRick Olson <technoweenie@gmail.com>2006-03-24 14:46:17 +0000
commit38bae0a9695aeaf200b5d62cee2dba2928c847d9 (patch)
tree9d22babe8d9ebf70e6e095a4e4e78bcb5ffb0e8a /activerecord/test
parentcb069ea7cc0c530b6d1a3cbd636d728568b3f041 (diff)
downloadrails-38bae0a9695aeaf200b5d62cee2dba2928c847d9.tar.gz
rails-38bae0a9695aeaf200b5d62cee2dba2928c847d9.tar.bz2
rails-38bae0a9695aeaf200b5d62cee2dba2928c847d9.zip
Change has_many :through to use the :source option to specify the source association. :class_name is now ignored. [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations_cascaded_eager_loading_test.rb4
-rw-r--r--activerecord/test/fixtures/author.rb2
-rw-r--r--activerecord/test/fixtures/post.rb4
3 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/test/associations_cascaded_eager_loading_test.rb b/activerecord/test/associations_cascaded_eager_loading_test.rb
index 166d2b2262..dd12d529a2 100644
--- a/activerecord/test/associations_cascaded_eager_loading_test.rb
+++ b/activerecord/test/associations_cascaded_eager_loading_test.rb
@@ -87,7 +87,7 @@ class CascadedEagerLoadingTest < Test::Unit::TestCase
end
def test_eager_association_loading_with_multiple_stis_and_order
- author = Author.find(:first, :include => { :posts => [ :special_comments , :very_special_comment ] }, :order => 'authors.name, special_comments.body, very_special_comments.body', :conditions => 'posts.id = 4')
+ author = Author.find(:first, :include => { :posts => [ :special_comments , :very_special_comment ] }, :order => 'authors.name, comments.body, very_special_comments_posts.body', :conditions => 'posts.id = 4')
assert_equal authors(:david), author
assert_no_queries do
author.posts.first.special_comments
@@ -96,7 +96,7 @@ class CascadedEagerLoadingTest < Test::Unit::TestCase
end
def test_eager_association_loading_of_stis_with_multiple_references
- authors = Author.find(:all, :include => { :posts => { :special_comments => { :post => [ :special_comments, :very_special_comment ] } } }, :order => 'special_comments.body, very_special_comments.body', :conditions => 'posts.id = 4')
+ authors = Author.find(:all, :include => { :posts => { :special_comments => { :post => [ :special_comments, :very_special_comment ] } } }, :order => 'comments.body, very_special_comments_posts.body', :conditions => 'posts.id = 4')
assert_equal [authors(:david)], authors
assert_no_queries do
authors.first.posts.first.special_comments.first.post.special_comments
diff --git a/activerecord/test/fixtures/author.rb b/activerecord/test/fixtures/author.rb
index df78a7ada8..1a9b6d788a 100644
--- a/activerecord/test/fixtures/author.rb
+++ b/activerecord/test/fixtures/author.rb
@@ -4,7 +4,7 @@ class Author < ActiveRecord::Base
has_many :posts_with_categories, :include => :categories, :class_name => "Post"
has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post"
has_many :comments, :through => :posts
- has_many :funky_comments, :through => :posts, :class_name => 'Comment'
+ has_many :funky_comments, :through => :posts, :source => :comments
has_many :special_posts, :class_name => "Post"
has_many :hello_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'hello'"
diff --git a/activerecord/test/fixtures/post.rb b/activerecord/test/fixtures/post.rb
index 14b1c18117..9b42fbdb27 100644
--- a/activerecord/test/fixtures/post.rb
+++ b/activerecord/test/fixtures/post.rb
@@ -28,12 +28,12 @@ class Post < ActiveRecord::Base
end
end
- has_many :funky_tags, :through => :taggings, :class_name => 'Tag'
+ has_many :funky_tags, :through => :taggings, :source => :tag
has_many :super_tags, :through => :taggings
has_one :tagging, :as => :taggable
has_many :invalid_taggings, :as => :taggable, :class_name => "Tagging", :conditions => 'taggings.id < 0'
- has_many :invalid_tags, :through => :invalid_taggings, :class_name => "Tag"
+ has_many :invalid_tags, :through => :invalid_taggings, :source => :tag
has_many :categorizations, :foreign_key => :category_id
has_many :authors, :through => :categorizations