Permalink
Browse files

Fix for nested :include with namespaced models.

[#260 state:committed]
  • Loading branch information...
1 parent 9aa9bad commit 0b95a2afab88851eea78926eb91462002ff8db9a Rich Bradley committed with jeremy Aug 9, 2009
@@ -1838,7 +1838,7 @@ def remove_duplicate_results!(base, records, associations)
descendant
end.flatten.compact
- remove_duplicate_results!(reflection.class_name.constantize, parent_records, associations[name]) unless parent_records.empty?
+ remove_duplicate_results!(reflection.klass, parent_records, associations[name]) unless parent_records.empty?
end
end
end
@@ -36,4 +36,17 @@ def test_table_name
assert_equal 'companies', MyApplication::Business::Client.table_name, 'table_name for ActiveRecord model subclass'
assert_equal 'company_contacts', MyApplication::Business::Client::Contact.table_name, 'table_name for ActiveRecord model enclosed by another ActiveRecord model'
end
+
+ def test_eager_loading_in_modules
+ # need to add an eager loading condition to force the eager loading model into
+ # the old join model, to test that. See http://dev.rubyonrails.org/ticket/9640
+ client_join_loaded = MyApplication::Business::Client.find(3, :include => {:firm => :account}, :conditions => 'accounts.id IS NOT NULL')
+ client_sequential_loaded = MyApplication::Business::Client.find(3, :include => {:firm => :account})
+
+ [client_join_loaded, client_sequential_loaded].each do |client|
+ assert_no_queries do
+ assert_not_nil(client.firm.account)
+ end
+ end
+ end
end
@@ -11,7 +11,7 @@ class Firm < Company
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
- has_one :account, :dependent => :destroy
+ has_one :account, :class_name => 'MyApplication::Billing::Account', :dependent => :destroy
end
class Client < Company

0 comments on commit 0b95a2a

Please sign in to comment.