Skip to content

Commit

Permalink
Modified Rich Bradley's test-case to fail as part of suite and with a…
Browse files Browse the repository at this point in the history
… reasonable message

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
ratnikov authored and jeremy committed Aug 9, 2009
1 parent 22b38c1 commit f16008a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions activerecord/test/cases/modules_test.rb
Expand Up @@ -4,6 +4,16 @@
class ModulesTest < ActiveRecord::TestCase class ModulesTest < ActiveRecord::TestCase
fixtures :accounts, :companies, :projects, :developers 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 def test_module_spanning_associations
firm = MyApplication::Business::Firm.find(:first) firm = MyApplication::Business::Firm.find(:first)
assert !firm.clients.empty?, "Firm should have clients" assert !firm.clients.empty?, "Firm should have clients"
Expand Down Expand Up @@ -40,8 +50,12 @@ def test_table_name
def test_eager_loading_in_modules def test_eager_loading_in_modules
# need to add an eager loading condition to force the eager loading model into # 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 # 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') begin
client_sequential_loaded = MyApplication::Business::Client.find(3, :include => {:firm => :account}) 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| [client_join_loaded, client_sequential_loaded].each do |client|
assert_no_queries do assert_no_queries do
Expand Down

0 comments on commit f16008a

Please sign in to comment.