aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-23 18:13:08 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-23 18:13:08 -0700
commit9b47142ce120d0a7d715648259ffa238526d1f82 (patch)
tree5e0db52435292e06f0e482cc6c1611a179cf6e69 /activerecord/test/cases/associations/has_many_through_associations_test.rb
parent9e60f0f630f5e122296d05da0cf2d3b3d55526a5 (diff)
downloadrails-9b47142ce120d0a7d715648259ffa238526d1f82.tar.gz
rails-9b47142ce120d0a7d715648259ffa238526d1f82.tar.bz2
rails-9b47142ce120d0a7d715648259ffa238526d1f82.zip
adding a test for sti on middle tables with sorting on RHS
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb15
1 files changed, 14 insertions, 1 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 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