diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-27 16:56:49 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-27 16:56:49 -0700 |
commit | 3e0a60e4e2316ee696bdcf1c115582f8f450ad07 (patch) | |
tree | 9cfa220e983dd7baa633b65704becf1ebfa34a52 /activerecord/test/cases/associations | |
parent | f399538f99f9ae3311b694d7e579104ec98b899d (diff) | |
download | rails-3e0a60e4e2316ee696bdcf1c115582f8f450ad07.tar.gz rails-3e0a60e4e2316ee696bdcf1c115582f8f450ad07.tar.bz2 rails-3e0a60e4e2316ee696bdcf1c115582f8f450ad07.zip |
adding a test to demonstrate how to use STI subclasses on the far right
side of a hm:t association along with preloading.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
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') |