Created
September 27, 2013 23:45
-
-
Save tenderlove/6736768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 c0e80c5..5299e4e 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') | |
diff --git a/activerecord/test/models/contract.rb b/activerecord/test/models/contract.rb | |
index 2cf5aa7..cdf7b26 100644 | |
--- a/activerecord/test/models/contract.rb | |
+++ b/activerecord/test/models/contract.rb | |
@@ -1,6 +1,7 @@ | |
class Contract < ActiveRecord::Base | |
belongs_to :company | |
belongs_to :developer | |
+ belongs_to :firm, :foreign_key => 'company_id' | |
before_save :hi | |
after_save :bye | |
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb | |
index c8e2be5..a26de55 100644 | |
--- a/activerecord/test/models/developer.rb | |
+++ b/activerecord/test/models/developer.rb | |
@@ -38,6 +38,8 @@ class Developer < ActiveRecord::Base | |
has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id' | |
has_many :audit_logs | |
+ has_many :contracts | |
+ has_many :firms, :through => :contracts, :source => :firm | |
scope :jamises, -> { where(:name => 'Jamis') } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment