diff options
Diffstat (limited to 'activerecord/test/associations_join_model_test.rb')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index ee99d77931..bbe88cfbd5 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -9,7 +9,7 @@ require 'fixtures/categorization' class AssociationsJoinModelTest < Test::Unit::TestCase self.use_transactional_fixtures = false - fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings + fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites def test_has_many assert_equal categories(:general), authors(:david).categories.first @@ -294,6 +294,17 @@ class AssociationsJoinModelTest < Test::Unit::TestCase end end + def test_self_referential_has_many_through + assert_equal [authors(:mary)], authors(:david).favorite_authors + assert_equal [], authors(:mary).favorite_authors + end + + def test_add_to_self_referential_has_many_through + new_author = Author.create(:name => "Bob") + authors(:david).author_favorites.create :favorite_author => new_author + assert_equal [new_author, authors(:mary)], authors(:david).reload.favorite_authors + end + private # create dynamic Post models to allow different dependency options def find_post_with_dependency(post_id, association, association_name, dependency) |