Last active
July 7, 2019 09:41
-
-
Save kamipo/e9d609c1f57de784c79a7f854d44be57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb | |
index e0dac01f4a..ebba6b28b7 100644 | |
--- a/activerecord/test/cases/associations/inner_join_association_test.rb | |
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb | |
@@ -13,7 +13,18 @@ | |
class InnerJoinAssociationTest < ActiveRecord::TestCase | |
fixtures :authors, :author_addresses, :essays, :posts, :comments, :categories, :categories_posts, :categorizations, | |
- :taggings, :tags | |
+ :taggings, :tags, :people | |
+ | |
+ def test_includes | |
+ person = Person.includes(agents: { agents: :agents }).last | |
+ | |
+ assert person | |
+ assert_no_queries do | |
+ assert person.agents.last | |
+ assert person.agents.last.agents.last | |
+ assert person.agents.last.agents.last.primary_contact.agents.last.agents.last | |
+ end | |
+ end | |
def test_construct_finder_sql_applies_aliases_tables_on_association_conditions | |
result = Author.joins(:thinking_posts, :welcome_posts).to_a | |
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb | |
index 0dfd29e45e..99e8cdc464 100644 | |
--- a/activerecord/test/models/person.rb | |
+++ b/activerecord/test/models/person.rb | |
@@ -28,7 +28,7 @@ class Person < ActiveRecord::Base | |
has_many :jobs_with_dependent_nullify, source: :job, through: :references, dependent: :nullify | |
belongs_to :primary_contact, class_name: "Person" | |
- has_many :agents, class_name: "Person", foreign_key: "primary_contact_id" | |
+ has_many :agents, class_name: "Person", foreign_key: "primary_contact_id", inverse_of: :primary_contact | |
has_many :agents_of_agents, through: :agents, source: :agents | |
belongs_to :number1_fan, class_name: "Person" | |
Author
kamipo
commented
Jul 6, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment