neo4jrb/neo4j-core — pull request #116 by subvertallchris (2014-09-28 17:41:25+00:00)
Title: better tx support

Round two! This provides full (as far as I can tell) support in Rails and where tested in Core. I'm not an expert at using Core so I'm not sure if more tests are necessary. I went with a few basic e2e tests to prove that transactions return normal CypherNode and CypherRelationship objects. As far as Rails is concerned, the entire `active_model_spec.rb` e2e file passes when wrapped in transactions.

This ended up being so much easier to implement than expected. [This](https://github.com/neo4jrb/neo4j-core/compare/master...full_tx-alternate#diff-e5434f25d36a06f1cd47250fb886c312R29) is the key. We tell the transactional endpoint to include the REST response along with its default response. By doing that, we end up with an additional hash containing the same data in the same format as we would receive if we weren't using transactions.

With the response modified, it's easy to determine whether a response did or did not come from the transactional endpoint. You find that [here](https://github.com/neo4jrb/neo4j-core/compare/master...full_tx-alternate#diff-667161f645762badf396b66ceecafcb0R75). Along the way, we [add two instance variables](https://github.com/neo4jrb/neo4j-core/compare/master...full_tx-alternate#diff-667161f645762badf396b66ceecafcb0R53) to keep track of how deep in the hash we need to go to find our results.

This includes an update to `spec_helper.rb` that will wipe all indexes and constraints upon completion of the tests. [Here](https://github.com/neo4jrb/neo4j-core/compare/master...full_tx-alternate#diff-93830fa29d616f7c87903d08b5b1b29aR81). It's good for system health.