Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.ruby == 'ruby' }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
ruby: [ jruby-9.3.10.0, ruby-3.2.0 ]
neo4j: [ 3.5.35, 4.0.12, 4.1.12, 4.2.19, 4.3.23, 4.4.17, 5.4.0 ]
env:
NEO4J_VERSION: ${{ matrix.neo4j }}
JRUBY_OPTS: --debug -J-Xmx1280m -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xcompile.mode=OFF
steps:
- name: Start neo4j
run: docker run --name neo4j --env NEO4J_AUTH=neo4j/password --env NEO4J_ACCEPT_LICENSE_AGREEMENT=yes -p7687:7687 -p7474:7474 --rm neo4j:${{ matrix.neo4j }}-enterprise &

- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install dependencies
run: bundle update

- name: Wait for neo4j
run: while [ $((curl localhost:7474/ > /dev/null 2>&1); echo $?) -ne 0 ]; do sleep 1; done

- name: Run tests
run: bundle exec rspec
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions cancancan-activegraph.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files lib init.rb cancancan-activegraph.gemspec`.split($INPUT_RECORD_SEPARATOR)
spec.require_paths = ['lib']

spec.add_dependency 'activegraph', '>= 10.0.0'
spec.add_dependency 'activegraph', '>= 11.2.0'
spec.add_dependency 'cancancan'

spec.add_development_dependency 'bundler', '>= 1.3'
spec.add_development_dependency("neo4j-#{RUBY_PLATFORM =~ /java/ ? 'java' : 'ruby'}-driver", '>= 0.3.0')
spec.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
spec.add_development_dependency 'pry', '>= 0.11.3'
spec.add_development_dependency 'rake', '>= 10.1'
Expand Down
12 changes: 6 additions & 6 deletions lib/cancancan/active_graph/cypher_constructor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def construct_cypher(rule_cyphers)
rule_cyphers.each do |rule_cypher|
construct_cypher_for_rule(rule_cypher)
end
unwind_query_with_distinct
unwind_query_with_distinct(rule_cyphers.map { |rc| "#{rc.options[:var_label]}_col" })
end

def construct_cypher_for_rule(rule_cypher)
Expand All @@ -39,14 +39,14 @@ def update_scope(rule_cypher)
@scope = rule_cypher.options[:scope]
end

def unwind_query_with_distinct
def unwind_query_with_distinct(vars)
var = CanCanCan::ActiveGraph::CypherConstructorHelper.var_name(@model_class)
@query = unwind_qeury("#{var}_can")
@query = unwind_qeury("#{var}_can", vars)
.with("DISTINCT #{var}_can as #{var}")
end

def unwind_qeury(var_name)
@query = @query.unwind("#{@current_collection} as #{var_name}")
def unwind_qeury(var_name, vars = [@current_collection])
@query = @query.unwind("#{vars.join(' + ')} as #{var_name}")
end

def construct_can_cypher(rule_cypher)
Expand All @@ -60,7 +60,7 @@ def with_clause_for_rule(rule_cypher, can_rule)
var = rule_cypher.options[:var_label]
with = "collect(DISTINCT #{var}) as #{var}_col"
if can_rule && @current_collection
with = "#{@current_collection} + #{with}"
with = "#{@current_collection}, #{with}"
end
@current_collection = "#{var}_col"
with
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

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

set_default_driver
Expand Down