diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-04-22 16:28:20 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-12 18:01:57 +0900 |
commit | fa8c525d20ff14e4a9d367d2845b446267065bcc (patch) | |
tree | 1753880cb6c0ecc20f43a1528bce09a8857c1509 /activerecord/test/cases/associations/inverse_associations_test.rb | |
parent | 3bd534287139549cee10e10364344d66139d9237 (diff) | |
download | rails-fa8c525d20ff14e4a9d367d2845b446267065bcc.tar.gz rails-fa8c525d20ff14e4a9d367d2845b446267065bcc.tar.bz2 rails-fa8c525d20ff14e4a9d367d2845b446267065bcc.zip |
Fix `automatic_inverse_of` not to be disabled if extension block is given
If an association has a scope, `automatic_inverse_of` is to be disabled.
But extension block is obviously not a scope. It should not be regarded
as a scope.
Fixes #28806.
Diffstat (limited to 'activerecord/test/cases/associations/inverse_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 9 |
1 files changed, 9 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..669e176dcb 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -8,6 +8,7 @@ require "models/zine" require "models/club" require "models/sponsor" require "models/rating" +require "models/post" require "models/comment" require "models/car" require "models/bulb" @@ -62,6 +63,14 @@ class AutomaticInverseFindingTests < ActiveRecord::TestCase assert_equal rating_reflection, comment_reflection.inverse_of, "The Comment reflection's inverse should be the Rating reflection" end + def test_has_many_and_belongs_to_should_find_inverse_automatically_for_extension_block + comment_reflection = Comment.reflect_on_association(:post) + post_reflection = Post.reflect_on_association(:comments) + + assert_predicate post_reflection, :has_inverse? + assert_equal comment_reflection, post_reflection.inverse_of + end + def test_has_many_and_belongs_to_should_find_inverse_automatically_for_sti author_reflection = Author.reflect_on_association(:posts) author_child_reflection = Author.reflect_on_association(:special_posts) |