From 9b47142ce120d0a7d715648259ffa238526d1f82 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 23 Sep 2013 18:13:08 -0700 Subject: adding a test for sti on middle tables with sorting on RHS --- .../associations/has_many_through_associations_test.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb') 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 99c71a1dd9..149c9576ca 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -29,7 +29,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase fixtures :posts, :readers, :people, :comments, :authors, :categories, :taggings, :tags, :owners, :pets, :toys, :jobs, :references, :companies, :members, :author_addresses, :subscribers, :books, :subscriptions, :developers, :categorizations, :essays, - :categories_posts + :categories_posts, :clubs, :memberships # Dummies to force column loads so query counts are clean. def setup @@ -37,6 +37,19 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase Reader.create :person_id => 0, :post_id => 0 end + def test_preload_sti_middle_relation + club = Club.create!(name: 'Aaron cool banana club') + member1 = Member.create!(name: 'Aaron') + member2 = Member.create!(name: 'Cat') + + SuperMembership.create! club: club, member: member1 + CurrentMembership.create! club: club, member: member2 + + club1 = Club.includes(:members).find_by_id club.id + left, right = club1.members.map(&:id) + assert_operator left, :>, right + end + def make_model(name) Class.new(ActiveRecord::Base) { define_singleton_method(:name) { name } } end -- cgit v1.2.3