Skip to content

Commit

Permalink
Merge branch 'master' of github.com:andreasronge/neo4j-core
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Oct 23, 2014
2 parents a930f73 + 6f9b4a5 commit 3794356
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
16 changes: 8 additions & 8 deletions lib/neo4j-server/cypher_response.rb
Expand Up @@ -74,13 +74,13 @@ def map_row_value(value, session)

def hash_value_as_object(value, session)
return value unless value['labels'] || value['type'] || is_transaction_response?
obj_type, data = if value['labels'] || value['type']
add_entity_id(value)
[(value['labels'] ? CypherNode : CypherRelationship), value]
else
add_transaction_entity_id
[(mapped_rest_data['start'] ? CypherRelationship : CypherNode), mapped_rest_data]
end
obj_type, data = if is_transaction_response?
add_transaction_entity_id
[(mapped_rest_data['start'] ? CypherRelationship : CypherNode), mapped_rest_data]
else value['labels'] || value['type']
add_entity_id(value)
[(value['labels'] ? CypherNode : CypherRelationship), value]
end
obj_type.new(session, data).wrapper
end

Expand Down Expand Up @@ -196,7 +196,7 @@ def self.create_with_tx(response)
end

def is_transaction_response?
!self.response.body['results'].nil?
self.response.respond_to?('body') && !self.response.body['commit'].nil?
end

def rest_data
Expand Down
11 changes: 11 additions & 0 deletions spec/neo4j-server/e2e/cypher_node_spec.rb
Expand Up @@ -6,6 +6,17 @@
it_behaves_like "Neo4j::Node with tx"

describe 'transactions' do
around(:each) do |example|
begin
Neo4j::Transaction.run do |tx|
example.run
end
rescue RuntimeError
end
end

it_behaves_like "Neo4j::Node auto tx"

let!(:bob) { Neo4j::Node.create({ name: 'bob' }, :person) }
let!(:jim) { Neo4j::Node.create({ name: 'jim' }, :person) }

Expand Down
13 changes: 5 additions & 8 deletions spec/shared_examples/node_auto_tx.rb
Expand Up @@ -6,14 +6,6 @@


context "with auto commit" do
# before(:each) do
# @tx = Neo4j::Transaction.new
# end

# after(:each) do
# @tx.close
# end

describe "class methods" do
describe 'create()' do

Expand Down Expand Up @@ -101,11 +93,13 @@
it "deletes the node" do
expect(n).to exist
n.del
Neo4j::Transaction.current.close if Neo4j::Transaction.current
expect(n).not_to exist
end

it 'raise an exception if node does not exist' do
n.del
Neo4j::Transaction.current.close if Neo4j::Transaction.current
expect { n.del }.to raise_error
end

Expand All @@ -114,18 +108,21 @@
rel = n.create_rel(:friends, m)
expect(rel).to exist
n.del
Neo4j::Transaction.current.close if Neo4j::Transaction.current
expect(n).not_to exist
expect(rel).not_to exist
end

it 'is aliased to delete' do
n
n.delete
Neo4j::Transaction.current.close if Neo4j::Transaction.current
expect(n).not_to exist
end

it 'is aliased to destroy' do
n.destroy
Neo4j::Transaction.current.close if Neo4j::Transaction.current
expect(n).not_to exist
end
end
Expand Down

0 comments on commit 3794356

Please sign in to comment.