diff options
author | Fabian Schwahn <fabian.schwahn@gmail.com> | 2017-04-20 10:59:20 +0200 |
---|---|---|
committer | Fabian Schwahn <fabian.schwahn@gmail.com> | 2017-04-20 11:09:53 +0200 |
commit | dc47c2be4eb28a92e7fc0f2195b81ed453b8245d (patch) | |
tree | cb808a6196bb6d261fbbc3c941109535f04cf2d5 /activerecord/test/cases | |
parent | 809421811440391d596c63fb65e2a4a0424027ef (diff) | |
download | rails-dc47c2be4eb28a92e7fc0f2195b81ed453b8245d.tar.gz rails-dc47c2be4eb28a92e7fc0f2195b81ed453b8245d.tar.bz2 rails-dc47c2be4eb28a92e7fc0f2195b81ed453b8245d.zip |
Remove :polymorphic from INVALID_AUTOMATIC_INVERSE_OPTIONS
This makes automatic inverse detection possible for polymorphic
:has_one & :has_many possible.
This resolves a number of issues, eg. `touch: true` on polymorphic relationships (#16446) and automatically setting inverse associations on newly built objects (#15028, #21843).
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 287b3e9ebc..cf51f1009f 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -116,15 +116,11 @@ class AutomaticInverseFindingTests < ActiveRecord::TestCase 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 + def test_polymorphic_has_one_should_find_inverse_automatically 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" + assert man_reflection.has_inverse? end end |