specs to ensure connection is not returned to pool in nested transaction

This commit is contained in:
Brian J. Cardiff 2016-12-14 10:57:12 -03:00
parent c491bd8962
commit 882253bf4a

View file

@ -124,4 +124,37 @@ describe DB::SavePointTransaction do
top.rolledback.should be_false top.rolledback.should be_false
top.committed.should be_true top.committed.should be_true
end end
it "releasing result_set from within inner transaction should not return connection to pool" do
cnn = uninitialized DB::Connection
with_dummy do |db|
db.transaction do |tx|
tx.transaction do |inner|
cnn = inner.connection
cnn.scalar "1"
db.pool.is_available?(cnn).should be_false
end
db.pool.is_available?(cnn).should be_false
end
db.pool.is_available?(cnn).should be_true
end
end
it "releasing result_set from within inner inner transaction should not return connection to pool" do
cnn = uninitialized DB::Connection
with_dummy do |db|
db.transaction do |tx|
tx.transaction do |inner|
inner.transaction do |inner_inner|
cnn = inner_inner.connection
cnn.scalar "1"
db.pool.is_available?(cnn).should be_false
end
db.pool.is_available?(cnn).should be_false
end
db.pool.is_available?(cnn).should be_false
end
db.pool.is_available?(cnn).should be_true
end
end
end end