1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/cases/connection_pool_test.rb
Manfred Stienstra 809409d92f Add test case for ActiveRecord::ConnectionAdapters::ConnectionManagement.
- Make sure ConnectionManagement clears connections after each call, except in tests

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-02-25 12:48:53 -06:00

25 lines
No EOL
716 B
Ruby

require "cases/helper"
class ConnectionManagementTest < ActiveRecord::TestCase
def setup
@env = {}
@app = stub('App')
@management = ActiveRecord::ConnectionAdapters::ConnectionManagement.new(@app)
@connections_cleared = false
ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true }
end
test "clears active connections after each call" do
@app.expects(:call).with(@env)
@management.call(@env)
assert @connections_cleared
end
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
end