diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-08-29 16:00:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 16:00:41 -0500 |
commit | ed1eda271c7ac82ecb7bd94b6fa1b0093e648a3e (patch) | |
tree | 2423c670f8314d1ca6bae2e58077c7cdbc42056e /activerecord/test | |
parent | 3d2caab7dc92a13d4dd369678d5b4ce659df8e52 (diff) | |
parent | 1c7275a0ba05aaa27e5999eaa10b698d890fa157 (diff) | |
download | rails-ed1eda271c7ac82ecb7bd94b6fa1b0093e648a3e.tar.gz rails-ed1eda271c7ac82ecb7bd94b6fa1b0093e648a3e.tar.bz2 rails-ed1eda271c7ac82ecb7bd94b6fa1b0093e648a3e.zip |
Merge pull request #33729 from kddeisz/plural-automatic-inverse
Find inverse associations with plural names
Diffstat (limited to 'activerecord/test')
-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 da3a42e2b5..0808aa7a52 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -20,6 +20,7 @@ require "models/company" require "models/project" require "models/author" require "models/post" +require "models/department" class AutomaticInverseFindingTests < ActiveRecord::TestCase fixtures :ratings, :comments, :cars @@ -724,6 +725,16 @@ class InversePolymorphicBelongsToTests < ActiveRecord::TestCase # fails because Interest does have the correct inverse_of assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.first.polymorphic_man = Interest.first } end + + def test_favors_has_one_associations_for_inverse_of + inverse_name = Post.reflect_on_association(:author).inverse_of.name + assert_equal :post, inverse_name + end + + def test_finds_inverse_of_for_plural_associations + inverse_name = Department.reflect_on_association(:hotel).inverse_of.name + assert_equal :departments, inverse_name + end end # NOTE - these tests might not be meaningful, ripped as they were from the parental_control plugin |