mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Merge pull request #308 from dpisarewski/neo4j
Description of configuration options for Neo4j and some improvements
This commit is contained in:
commit
e331222c55
3 changed files with 24 additions and 4 deletions
|
@ -341,6 +341,11 @@ Usage beyond that remains the same with `DatabaseCleaner.start` calling any setu
|
|||
<td><code>DatabaseCleaner[:ohm]</code></td>
|
||||
<td>Connection specified as Redis URI</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Neo4j</td>
|
||||
<td><code>DatabaseCleaner[:neo4j]</code></td>
|
||||
<td>Database type and path(URI) <code>DatabaseCleaner[:neo4j, connection: {type: :server_db, path: 'http://localhost:7475'}].</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -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.
|
||||
|
|
|
@ -6,7 +6,7 @@ class Neo4jWidget < Neo4j::Node
|
|||
end
|
||||
|
||||
def self.count
|
||||
Neo4j::Session.query.pluck('count(*) AS result').first
|
||||
Neo4j::Session.query.match('n').pluck('COUNT(n)').first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,9 +23,11 @@ module DatabaseCleaner
|
|||
private
|
||||
|
||||
def rollback
|
||||
return unless tx
|
||||
if tx
|
||||
tx.failure
|
||||
tx.close
|
||||
end
|
||||
ensure
|
||||
self.tx = nil
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue