aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRich Bradley <richbradley@gmail.com>2009-08-08 23:29:38 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-09 00:31:46 -0700
commit9bb8ef9edebf5c27b8a1c67ca3776d52afbc1dc4 (patch)
treefa7154082c74f53d2441407786ce72ecb68903da /activerecord/test
parent0d539947017e0ba04601889e2a3e01a64bcadf69 (diff)
downloadrails-9bb8ef9edebf5c27b8a1c67ca3776d52afbc1dc4.tar.gz
rails-9bb8ef9edebf5c27b8a1c67ca3776d52afbc1dc4.tar.bz2
rails-9bb8ef9edebf5c27b8a1c67ca3776d52afbc1dc4.zip
Fix for nested :include with namespaced models.
[#260 state:committed]
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/modules_test.rb13
-rw-r--r--activerecord/test/models/company_in_module.rb2
2 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/test/cases/modules_test.rb b/activerecord/test/cases/modules_test.rb
index 283333fc04..8360416aa2 100644
--- a/activerecord/test/cases/modules_test.rb
+++ b/activerecord/test/cases/modules_test.rb
@@ -36,4 +36,17 @@ class ModulesTest < ActiveRecord::TestCase
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
diff --git a/activerecord/test/models/company_in_module.rb b/activerecord/test/models/company_in_module.rb
index 8b84c2fb5e..cdda7a44d4 100644
--- a/activerecord/test/models/company_in_module.rb
+++ b/activerecord/test/models/company_in_module.rb
@@ -13,7 +13,7 @@ module MyApplication
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