diff options
author | Andrew S. Brown <andrew@dontfidget.com> | 2014-05-26 11:52:46 -0700 |
---|---|---|
committer | Andrew S. Brown <andrew@dontfidget.com> | 2014-06-10 21:46:12 -0700 |
commit | 9feadc11a71b655dd7748c0f3a92bc411c9e63c2 (patch) | |
tree | f092bdda0e4ff4fd375557e2afe3a2169e121a79 /activerecord/test/cases | |
parent | d075c84320fab51992a1ab7d020c62ff1bad0b4e (diff) | |
download | rails-9feadc11a71b655dd7748c0f3a92bc411c9e63c2.tar.gz rails-9feadc11a71b655dd7748c0f3a92bc411c9e63c2.tar.bz2 rails-9feadc11a71b655dd7748c0f3a92bc411c9e63c2.zip |
use name specified by 'as' for automatic inverse association to avoid reflecting on wrong association
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 893030345f..59b8226c33 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -100,6 +100,17 @@ class AutomaticInverseFindingTests < ActiveRecord::TestCase assert_respond_to club_reflection, :has_inverse? assert !club_reflection.has_inverse?, "A has_many_through association should not find an inverse automatically" end + + def test_polymorphic_relationships_should_still_not_have_inverses_when_non_polymorphic_relationship_has_the_same_name + man_reflection = Man.reflect_on_association(:polymorphic_face_without_inverse) + face_reflection = Face.reflect_on_association(:man) + + assert_respond_to face_reflection, :has_inverse? + assert face_reflection.has_inverse?, "For this test, the non-polymorphic association must have an inverse" + + assert_respond_to man_reflection, :has_inverse? + assert !man_reflection.has_inverse?, "The target of a polymorphic association should not find an inverse automatically" + end end class InverseAssociationTests < ActiveRecord::TestCase |