提交 809409d9 编写于 作者: M Manfred Stienstra 提交者: Joshua Peek

Add test case for ActiveRecord::ConnectionAdapters::ConnectionManagement.

- Make sure ConnectionManagement clears connections after each call, except in tests
Signed-off-by: NJoshua Peek <josh@joshpeek.com>
上级 0a8c003b
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
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册