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:
parent
25f94971ab
commit
aea1477362
2 changed files with 10 additions and 5 deletions
|
@ -116,7 +116,11 @@ module ActiveRecord
|
|||
connection_handler.remove_connection(klass)
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,8 +20,9 @@ module ActiveRecord
|
|||
@app = App.new
|
||||
@management = ConnectionManagement.new(@app)
|
||||
|
||||
@connections_cleared = false
|
||||
ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true }
|
||||
# make sure we have an active connection
|
||||
assert ActiveRecord::Base.connection
|
||||
assert ActiveRecord::Base.connection_handler.active_connections?
|
||||
end
|
||||
|
||||
def test_app_delegation
|
||||
|
@ -33,13 +34,13 @@ module ActiveRecord
|
|||
|
||||
test "clears active connections after each call" do
|
||||
@management.call(@env)
|
||||
assert @connections_cleared
|
||||
assert !ActiveRecord::Base.connection_handler.active_connections?
|
||||
end
|
||||
|
||||
test "doesn't clear active connections when running in a test case" do
|
||||
@env['rack.test'] = true
|
||||
@management.call(@env)
|
||||
assert !@connections_cleared
|
||||
assert ActiveRecord::Base.connection_handler.active_connections?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue