aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-13 18:19:18 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-13 18:19:18 -0300
commit4c0a1021e51bfb8f3623480f577f7f52d83a0fc7 (patch)
tree2aaff660948a48ff70a4351446f9f1a1a8908ea5 /activerecord/test/cases
parentc28e436aae4a13225d86e00094a5fa72d82fc297 (diff)
parent9feadc11a71b655dd7748c0f3a92bc411c9e63c2 (diff)
downloadrails-4c0a1021e51bfb8f3623480f577f7f52d83a0fc7.tar.gz
rails-4c0a1021e51bfb8f3623480f577f7f52d83a0fc7.tar.bz2
rails-4c0a1021e51bfb8f3623480f577f7f52d83a0fc7.zip
Merge pull request #15343 from dontfidget/fix_polymorphic_automatic_inverse_of
prevent bad automatic inverse_of association
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb11
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 a674a39d65..60df4e14dd 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