aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorJoe Hannon <ziggurism@gmail.com>2010-05-02 16:26:02 -0700
committerVijay Dev <vijaydev.cse@gmail.com>2010-12-16 01:49:29 +0530
commit7bffa9dd01cdef3088e0d33fabd5fc07eb35c9d9 (patch)
treedae7e743fd85629b8f0ef61269e47096ff4f0693 /activerecord/test/cases/associations/has_many_through_associations_test.rb
parenta64bf22a718bcc8d1a33234ab8a7cdd91c6d537b (diff)
downloadrails-7bffa9dd01cdef3088e0d33fabd5fc07eb35c9d9.tar.gz
rails-7bffa9dd01cdef3088e0d33fabd5fc07eb35c9d9.tar.bz2
rails-7bffa9dd01cdef3088e0d33fabd5fc07eb35c9d9.zip
add test which fails for has_many through self join [#4361 state:open]
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 52432b0428..fe60e676d6 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -388,6 +388,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
].each {|block| assert_raise(ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection, &block) }
end
+ def test_has_many_association_through_a_has_many_association_to_self
+ sarah = Person.create!(:first_name => 'Sarah', :primary_contact_id => people(:susan).id, :gender => 'F', :number1_fan_id => 1)
+ john = Person.create!(:first_name => 'John', :primary_contact_id => sarah.id, :gender => 'M', :number1_fan_id => 1)
+ assert_equal sarah.agents, [john]
+ assert_equal people(:susan).agents_of_agents, [john]
+ end
+
def test_collection_singular_ids_getter_with_string_primary_keys
book = books(:awdr)
assert_equal 2, book.subscriber_ids.size