From 3e0a60e4e2316ee696bdcf1c115582f8f450ad07 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 27 Sep 2013 16:56:49 -0700 Subject: adding a test to demonstrate how to use STI subclasses on the far right side of a hm:t association along with preloading. --- .../test/cases/associations/has_many_through_associations_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index c0e80c5fe9..5299e4e17e 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -37,6 +37,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase Reader.create :person_id => 0, :post_id => 0 end + def test_preload_sti_rhs_class + developers = Developer.includes(:firms).all.to_a + assert_no_queries do + developers.each { |d| d.firms } + end + end + def test_preload_sti_middle_relation club = Club.create!(name: 'Aaron cool banana club') member1 = Member.create!(name: 'Aaron') -- cgit v1.2.3