1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

make sure we have an active database connection before running each connection management test

This commit is contained in:
Aaron Patterson 2011-03-28 17:47:46 -07:00
parent 25f94971ab
commit aea1477362
2 changed files with 10 additions and 5 deletions

View file

@ -116,7 +116,11 @@ module ActiveRecord
connection_handler.remove_connection(klass) connection_handler.remove_connection(klass)
end end
delegate :clear_active_connections!, :clear_reloadable_connections!, def clear_active_connections!
connection_handler.clear_active_connections!
end
delegate :clear_reloadable_connections!,
:clear_all_connections!,:verify_active_connections!, :to => :connection_handler :clear_all_connections!,:verify_active_connections!, :to => :connection_handler
end end
end end

View file

@ -20,8 +20,9 @@ module ActiveRecord
@app = App.new @app = App.new
@management = ConnectionManagement.new(@app) @management = ConnectionManagement.new(@app)
@connections_cleared = false # make sure we have an active connection
ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true } assert ActiveRecord::Base.connection
assert ActiveRecord::Base.connection_handler.active_connections?
end end
def test_app_delegation def test_app_delegation
@ -33,13 +34,13 @@ module ActiveRecord
test "clears active connections after each call" do test "clears active connections after each call" do
@management.call(@env) @management.call(@env)
assert @connections_cleared assert !ActiveRecord::Base.connection_handler.active_connections?
end end
test "doesn't clear active connections when running in a test case" do test "doesn't clear active connections when running in a test case" do
@env['rack.test'] = true @env['rack.test'] = true
@management.call(@env) @management.call(@env)
assert !@connections_cleared assert ActiveRecord::Base.connection_handler.active_connections?
end end
end end
end end