2009-02-25 04:29:22 -05:00
|
|
|
require "cases/helper"
|
|
|
|
|
|
|
|
class ConnectionManagementTest < ActiveRecord::TestCase
|
|
|
|
def setup
|
|
|
|
@env = {}
|
|
|
|
@app = stub('App')
|
|
|
|
@management = ActiveRecord::ConnectionAdapters::ConnectionManagement.new(@app)
|
2010-07-16 16:50:58 -04:00
|
|
|
|
2009-02-25 04:29:22 -05:00
|
|
|
@connections_cleared = false
|
|
|
|
ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true }
|
|
|
|
end
|
2010-07-16 16:50:58 -04:00
|
|
|
|
2009-02-25 04:29:22 -05:00
|
|
|
test "clears active connections after each call" do
|
|
|
|
@app.expects(:call).with(@env)
|
|
|
|
@management.call(@env)
|
|
|
|
assert @connections_cleared
|
|
|
|
end
|
2010-07-16 16:50:58 -04:00
|
|
|
|
2009-02-25 04:29:22 -05:00
|
|
|
test "doesn't clear active connections when running in a test case" do
|
|
|
|
@env['rack.test'] = true
|
|
|
|
@app.expects(:call).with(@env)
|
|
|
|
@management.call(@env)
|
|
|
|
assert !@connections_cleared
|
|
|
|
end
|
2010-07-16 16:50:58 -04:00
|
|
|
end
|