aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Ratnikov <ratnikov@gmail.com>2009-08-09 03:35:45 -0500
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-09 02:40:27 -0700
commitf16008afddaf7d80d6bac0ace380e864b78106fe (patch)
tree6e95463a6d357bd04f11632c2f26d636722dbb83
parent22b38c18c61a18babd671b973e804e054ba795d4 (diff)
downloadrails-f16008afddaf7d80d6bac0ace380e864b78106fe.tar.gz
rails-f16008afddaf7d80d6bac0ace380e864b78106fe.tar.bz2
rails-f16008afddaf7d80d6bac0ace380e864b78106fe.zip
Modified Rich Bradley's test-case to fail as part of suite and with a reasonable message
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
-rw-r--r--activerecord/test/cases/modules_test.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/activerecord/test/cases/modules_test.rb b/activerecord/test/cases/modules_test.rb
index 8360416aa2..9c44bea74f 100644
--- a/activerecord/test/cases/modules_test.rb
+++ b/activerecord/test/cases/modules_test.rb
@@ -4,6 +4,16 @@ require 'models/company_in_module'
class ModulesTest < ActiveRecord::TestCase
fixtures :accounts, :companies, :projects, :developers
+ def setup
+ # need to make sure Object::Firm is not defined, so that constantize will not be able to cheat when having to load namespaced classes
+ @firm_const = Object.send(:remove_const, :Firm) if Object.const_defined?(:Firm)
+ end
+
+ def teardown
+ # reinstate the Object::Firm constant for further tests
+ Object.send :const_set, :Firm, @firm_const unless @firm_const.nil?
+ end
+
def test_module_spanning_associations
firm = MyApplication::Business::Firm.find(:first)
assert !firm.clients.empty?, "Firm should have clients"
@@ -40,8 +50,12 @@ class ModulesTest < ActiveRecord::TestCase
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})
+ begin
+ 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})
+ rescue NameError => nE
+ flunk "Should be able to resolve all classes via reflections"
+ end
[client_join_loaded, client_sequential_loaded].each do |client|
assert_no_queries do