From 7b1aa4f1263e584e97febcfb0c68aae69cbb5a1b Mon Sep 17 00:00:00 2001 From: Dieter Pisarewski Date: Fri, 12 Dec 2014 11:07:53 +0100 Subject: [PATCH] describe configuration options for neo4j --- README.markdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.markdown b/README.markdown index 7355da8..3523e0f 100644 --- a/README.markdown +++ b/README.markdown @@ -341,6 +341,11 @@ Usage beyond that remains the same with `DatabaseCleaner.start` calling any setu DatabaseCleaner[:ohm] Connection specified as Redis URI + + Neo4j + DatabaseCleaner[:neo4j] + Database type and path(URI) DatabaseCleaner[:neo4j, connection: {type: :server_db, path: 'http://localhost:7475'}]. + @@ -388,6 +393,19 @@ test: Due to an inconsistency in JRuby's implementation of Fibers, Sequel gives a different connection to `DatabaseCleaner.start` than is used for tests run between `.start` and `.clean`. This can be worked around by running your tests in a block like `DatabaseCleaner.cleaning { run_my_tests }` instead, which does not use Fibers. +### Model fails to load with Neo4j using transactions + +When you are using [neo4j](https://github.com/neo4jrb/neo4j) gem it creates schema and reads indexes upon loading models. These operations can't be done during a transaction. You have to preload your models before DatabaseCleaner starts a transaction. + +Add to your rails_helper or spec_helper after requiring database_cleaner: + +```ruby +require 'database_cleaner' +Dir["#{Rails.root}/app/models/**/*.rb"].each do |model| + load model +end +``` + ## Debugging In rare cases DatabaseCleaner will encounter errors that it will log. By default it uses STDOUT set to the ERROR level but you can configure this to use whatever Logger you desire.