Permalink
Browse files

A load of tests that need to be written

  • Loading branch information...
1 parent 3aba73f commit 7aea695815821df332913bae4b47714a525009a3 @jonleighton jonleighton committed Oct 12, 2010
Showing with 63 additions and 0 deletions.
  1. +63 −0 activerecord/test/cases/associations/nested_has_many_through_associations_test.rb
View
63 activerecord/test/cases/associations/nested_has_many_through_associations_test.rb
@@ -28,6 +28,26 @@ class NestedHasManyThroughAssociationsTest < ActiveRecord::TestCase
fixtures :authors, :books, :posts, :subscriptions, :subscribers, :tags, :taggings,
:people, :readers, :references, :jobs, :ratings, :comments
+ # Through associations can either use the has_many or has_one macros.
+ #
+ # has_many
+ # - Source reflection can be has_many, has_one, belongs_to or has_and_belongs_to_many
+ # - Through reflection can be has_many, has_one, belongs_to or has_and_belongs_to_many
+ #
+ # has_one
+ # - Source reflection can be has_one or belongs_to
+ # - Through reflection can be has_one or belongs_to
+ #
+ # Additionally, the source reflection and/or through reflection may be subject to
+ # polymorphism and/or STI.
+ #
+ # When testing these, we need to make sure it works via loading the association directly, or
+ # joining the association, or including the association. We also need to ensure that associations
+ # are readonly where relevant.
+
+ # has_many through
+ # Source: has_many through
+ # Through: has_many
def test_has_many_through_a_has_many_through_association_on_source_reflection
author = authors(:david)
assert_equal [tags(:general), tags(:general)], author.tags
@@ -41,6 +61,9 @@ def test_has_many_through_a_has_many_through_association_on_source_reflection
assert authors.empty?
end
+ # has_many through
+ # Source: has_many
+ # Through: has_many through
def test_has_many_through_a_has_many_through_association_on_through_reflection
author = authors(:david)
assert_equal [subscribers(:first), subscribers(:second), subscribers(:second)], author.subscribers
@@ -49,6 +72,46 @@ def test_has_many_through_a_has_many_through_association_on_through_reflection
authors = Author.joins(:subscribers).where('subscribers.nick' => 'alterself')
assert_equal [authors(:david)], authors
end
+
+ # TODO: has_many through
+ # Source: has_one through
+ # Through: has_one
+
+ # TODO: has_many through
+ # Source: has_one
+ # Through: has_one through
+
+ # TODO: has_many through
+ # Source: has_many through
+ # Through: has_one
+
+ # TODO: has_many through
+ # Source: has_many
+ # Through: has_one through
+
+ # TODO: has_many through
+ # Source: has_and_belongs_to_many
+ # Through: has_many
+
+ # TODO: has_many through
+ # Source: has_many
+ # Through: has_and_belongs_to_many
+
+ # TODO: has_many through
+ # Source: belongs_to
+ # Through: has_many through
+
+ # TODO: has_many through
+ # Source: has_many through
+ # Through: belongs_to
+
+ # TODO: has_one through
+ # Source: has_one through
+ # Through: has_one
+
+ # TODO: has_one through
+ # Source: belongs_to
+ # Through: has_one through
def test_distinct_has_many_through_a_has_many_through_association_on_source_reflection
author = authors(:david)

0 comments on commit 7aea695

Please sign in to comment.