aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations_join_model_test.rb10
-rw-r--r--activerecord/test/fixtures/author.rb1
-rw-r--r--activerecord/test/fixtures/post.rb1
3 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb
index db5f362610..4ea2b6e684 100644
--- a/activerecord/test/associations_join_model_test.rb
+++ b/activerecord/test/associations_join_model_test.rb
@@ -55,7 +55,11 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
def test_polymorphic_has_many_going_through_join_model_with_inheritance
assert_equal tags(:general), posts(:thinking).tags.first
end
-
+
+ def test_polymorphic_has_many_going_through_join_model_with_inheritance_with_custom_class_name
+ assert_equal tags(:general), posts(:thinking).funky_tags.first
+ end
+
def test_polymorphic_has_many_create_model_with_inheritance
post = posts(:thinking)
assert_instance_of SpecialPost, post
@@ -234,6 +238,10 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
assert_equal comments(:greetings), authors(:david).comments.find(:all, :order => 'comments.id').first
end
+ def test_has_many_through_has_many_find_all_with_custom_class
+ assert_equal comments(:greetings), authors(:david).funky_comments.find(:all, :order => 'comments.id').first
+ end
+
def test_has_many_through_has_many_find_first
assert_equal comments(:greetings), authors(:david).comments.find(:first, :order => 'comments.id')
end
diff --git a/activerecord/test/fixtures/author.rb b/activerecord/test/fixtures/author.rb
index 1a7aa6e388..1dda0f837c 100644
--- a/activerecord/test/fixtures/author.rb
+++ b/activerecord/test/fixtures/author.rb
@@ -4,6 +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 :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 23f4b5d8a5..eca9369723 100644
--- a/activerecord/test/fixtures/post.rb
+++ b/activerecord/test/fixtures/post.rb
@@ -22,6 +22,7 @@ class Post < ActiveRecord::Base
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
+ has_many :funky_tags, :through => :taggings, :class_name => 'Tag'
has_many :super_tags, :through => :taggings
has_one :tagging, :as => :taggable