Skip to content

Commit

Permalink
several changes for 10.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
klobuczek committed Dec 8, 2020
1 parent e871c43 commit 0dad770
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 37 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file.
This file should follow the standards specified on [http://keepachangelog.com/]
This project adheres to [Semantic Versioning](http://semver.org/).

## [10.0.2] 2020-12-08

## Fixed

- fixed bad require (https://github.com/neo4jrb/activegraph/issues/1634)
- removed unused exception class (Thanks @joshjordan)
- prevented after_commit callbacks from being called multiple times (Thanks @joshjordan)

## [10.0.1] 2020-07-26

## Fixed
Expand Down
3 changes: 1 addition & 2 deletions lib/active_graph/tasks/migration.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ require 'active_graph/migration'
if !defined?(Rails) && !Rake::Task.task_defined?('environment')
desc 'Run a script against the database to perform system-wide changes'
task :environment do
require 'active_graph/session_manager'
require 'ostruct'
neo4j_url = ENV['NEO4J_URL'] || 'http://localhost:7474'
neo4j_url = ENV['NEO4J_URL'] || 'bolt://localhost:7687'
$LOAD_PATH.unshift File.dirname('./')
ActiveGraph::Base.on_establish_driver do
Neo4j::Driver::GraphDatabase.driver(neo4j_url)
Expand Down
5 changes: 4 additions & 1 deletion lib/active_graph/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ def failure
def close
success
super
after_commit_registry.each(&:call) unless @failure
end

def after_commit(&block)
after_commit_registry << block
end

def apply_callbacks
after_commit_registry.each(&:call) unless @failure
end

private

def after_commit_registry
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def run_transaction_work(session, method, **config, &block)
session.send(method, **config) do |tx|
self.tx = tx
checked_yield(tx, &block)
end
end.tap { tx.apply_callbacks }
end

def checked_yield(tx)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActiveGraph
VERSION = '10.0.1'
VERSION = '10.0.2'
end
4 changes: 2 additions & 2 deletions spec/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## Configuration

The specs are configured to run against `http://localhost:7474` by default. In order to change this in your local setup you can set the `NEO4J_URL` environment variable on your system to suit your needs.
The specs are configured to run against `bolt://localhost:7687` by default. In order to change this in your local setup you can set the `NEO4J_URL` environment variable on your system to suit your needs.

To make this easier, the neo4j spec suite allows you to add a `.env` file locally to configure this. For example, to set the `NEO4J_URL` you simply need to add a `.env` file that looks like this:

```
NEO4J_URL=http://localhost:7475
NEO4J_URL=bolt://localhost:6998
```

49 changes: 20 additions & 29 deletions spec/active_graph/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,47 +135,38 @@ def get_object_by_id(id)

describe 'after_commit hook' do
it 'gets called when the root transaction is closed' do
data = false
expect do
subject.transaction do |tx1|
subject.transaction do |tx2|
subject.transaction do |tx3|
tx3.after_commit { data = true }
end
expect(self).to receive(:callback).once
subject.transaction do |tx1|
subject.transaction do |tx2|
subject.transaction do |tx3|
tx3.after_commit(&method(:callback))
end
end
end.to change { data }.to(true)
expect(data).to be_truthy
end
end

it 'is ignored when the root transaction fails' do
data = false
expect do
subject.transaction do |tx1|
subject.transaction do |tx2|
subject.transaction do |tx3|
tx3.after_commit { data = true }
end
expect(self).not_to receive(:callback)
subject.transaction do |tx1|
subject.transaction do |tx2|
subject.transaction do |tx3|
tx3.after_commit(&method(:callback))
end
tx1.failure
end
end.not_to change { data }
expect(data).to be_falsey
tx1.failure
end
end

it 'is ignored when a child transaction fails' do
data = false
expect do
subject.transaction do |tx1|
subject.transaction do |tx2|
subject.transaction do |tx3|
tx3.after_commit { data = true }
tx3.failure
end
expect(self).not_to receive(:callback)
subject.transaction do |tx1|
subject.transaction do |tx2|
subject.transaction do |tx3|
tx3.after_commit(&method(:callback))
tx3.failure
end
end
end.not_to change { data }
expect(data).to be_falsey
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def let_context(*args, &block)
ActiveGraph::Config[:logger_level] = Logger::DEBUG if ENV['DEBUG']

def set_default_driver
server_url = ENV['NEO4J_URL'] || 'bolt://localhost:6998'
server_url = ENV['NEO4J_URL'] || 'bolt://localhost:7687'
ActiveGraph::Base.driver =
Neo4j::Driver::GraphDatabase.driver(server_url, Neo4j::Driver::AuthTokens.none, encryption: false)
end
Expand Down

0 comments on commit 0dad770

Please sign in to comment.