Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
  2. index e0dac01f4a..ebba6b28b7 100644
  3. --- a/activerecord/test/cases/associations/inner_join_association_test.rb
  4. +++ b/activerecord/test/cases/associations/inner_join_association_test.rb
  5. @@ -13,7 +13,18 @@
  6.  
  7. class InnerJoinAssociationTest < ActiveRecord::TestCase
  8. fixtures :authors, :author_addresses, :essays, :posts, :comments, :categories, :categories_posts, :categorizations,
  9. - :taggings, :tags
  10. + :taggings, :tags, :people
  11. +
  12. + def test_includes
  13. + person = Person.includes(agents: { agents: :agents }).last
  14. +
  15. + assert person
  16. + assert_no_queries do
  17. + assert person.agents.last
  18. + assert person.agents.last.agents.last
  19. + assert person.agents.last.agents.last.primary_contact.agents.last.agents.last
  20. + end
  21. + end
  22.  
  23. def test_construct_finder_sql_applies_aliases_tables_on_association_conditions
  24. result = Author.joins(:thinking_posts, :welcome_posts).to_a
  25. diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
  26. index 0dfd29e45e..99e8cdc464 100644
  27. --- a/activerecord/test/models/person.rb
  28. +++ b/activerecord/test/models/person.rb
  29. @@ -28,7 +28,7 @@ class Person < ActiveRecord::Base
  30. has_many :jobs_with_dependent_nullify, source: :job, through: :references, dependent: :nullify
  31.  
  32. belongs_to :primary_contact, class_name: "Person"
  33. - has_many :agents, class_name: "Person", foreign_key: "primary_contact_id"
  34. + has_many :agents, class_name: "Person", foreign_key: "primary_contact_id", inverse_of: :primary_contact
  35. has_many :agents_of_agents, through: :agents, source: :agents
  36. belongs_to :number1_fan, class_name: "Person"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement