Skip to content

Commit

Permalink
simple test for autoclosing, needs more attention
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Oct 23, 2015
1 parent 4b23d5e commit 54ff175
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/neo4j/transaction.rb
Expand Up @@ -73,6 +73,12 @@ def close
return if @pushed_nested >= 0
fail "Can't commit transaction, already committed" if @pushed_nested < -1
Neo4j::Transaction.unregister(self)
post_close!
end

private

def post_close!
return if autoclosed?
if failed?
delete
Expand Down
11 changes: 11 additions & 0 deletions spec/neo4j-server/e2e/cypher_transaction_spec.rb
Expand Up @@ -84,6 +84,17 @@ module Server
end
end

describe 'autoclosing and #post_close!' do
# 10/23/2015: Having trouble making specs behave with transactions, leaving this as is to get things stable.
# TODO: Test this more thoroughly.
it 'only proceeds with delete/commit if not autoclosed' do
expect_any_instance_of(Neo4j::Server::CypherTransaction).to receive(:autoclosed?).and_return(false)
expect_any_instance_of(Neo4j::Server::CypherTransaction).to receive(:failed?).and_call_original
tx = Neo4j::Transaction.new
tx.close
end
end

describe Neo4j::Label do
describe '.find_nodes' do
it 'find and can load them' do
Expand Down

0 comments on commit 54ff175

Please sign in to comment.