aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/nested_has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorBodaniel Jeanes <me@bjeanes.com>2010-09-26 22:17:18 +1000
committerBodaniel Jeanes <me@bjeanes.com>2010-09-26 22:25:25 +1000
commitb689834bcf2730353d066277f43047f10abb8d30 (patch)
tree034aff3a33977cdb529ee70b0a45297b119582ca /activerecord/test/cases/associations/nested_has_many_through_associations_test.rb
parent14d2feeeab44d0161b3014c9e19f4e336c09c78e (diff)
downloadrails-b689834bcf2730353d066277f43047f10abb8d30.tar.gz
rails-b689834bcf2730353d066277f43047f10abb8d30.tar.bz2
rails-b689834bcf2730353d066277f43047f10abb8d30.zip
Initial nested_has_many_through support [#1152]
Diffstat (limited to 'activerecord/test/cases/associations/nested_has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/nested_has_many_through_associations_test.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/nested_has_many_through_associations_test.rb b/activerecord/test/cases/associations/nested_has_many_through_associations_test.rb
new file mode 100644
index 0000000000..36de709ffc
--- /dev/null
+++ b/activerecord/test/cases/associations/nested_has_many_through_associations_test.rb
@@ -0,0 +1,43 @@
+require "cases/helper"
+require 'models/author'
+require 'models/post'
+require 'models/person'
+require 'models/reference'
+require 'models/job'
+require 'models/reader'
+require 'models/comment'
+require 'models/tag'
+require 'models/tagging'
+require 'models/owner'
+require 'models/pet'
+require 'models/toy'
+require 'models/contract'
+require 'models/company'
+require 'models/developer'
+require 'models/subscriber'
+require 'models/book'
+require 'models/subscription'
+
+class NestedHasManyThroughAssociationsTest < ActiveRecord::TestCase
+ fixtures :authors, :books, :posts, :subscriptions, :subscribers, :tags, :taggings
+
+ def test_has_many_through_a_has_many_through_association_on_source_reflection
+ author = authors(:david)
+ assert_equal [tags(:general), tags(:general)], author.tags
+ end
+
+ 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
+ end
+
+ def test_distinct_has_many_through_a_has_many_through_association_on_source_reflection
+ author = authors(:david)
+ assert_equal [tags(:general)], author.distinct_tags
+ end
+
+ def test_distinct_has_many_through_a_has_many_through_association_on_through_reflection
+ author = authors(:david)
+ assert_equal [subscribers(:first), subscribers(:second)], author.distinct_subscribers
+ end
+end \ No newline at end of file