forked from neo4jrb/devise-activegraph
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Neo4j 3 / Rails 4 / Devise 3
- Loading branch information
1 parent
be07cfa
commit 4f0a453
Showing
14 changed files
with
132 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
require 'devise-neo4j' | ||
require 'orm_adapter/adapters/neo4j' | ||
require 'devise/orm/neo4j/date_time' | ||
require 'devise/orm/neo4j/compatibility' | ||
require 'devise/orm/neo4j/nil_class_converter' | ||
|
||
module Neo4j | ||
module Rails | ||
class Model | ||
include ActiveModel::Validations | ||
extend ::Devise::Models | ||
extend ::Devise::Orm::Neo4j::Hook | ||
end | ||
module ActiveNode | ||
include ActiveModel::Validations | ||
extend ::Devise::Models | ||
extend ::Devise::Orm::Neo4j::Hook | ||
end | ||
end | ||
|
||
|
||
converters = [ Neo4j::TypeConverters::NilClassConverter ] | ||
Neo4j::TypeConverters.constants.find_all do |c| | ||
converters << Neo4j::TypeConverters.const_get(c) if Neo4j::TypeConverters.const_get(c).respond_to?(:convert?) | ||
end | ||
Neo4j::TypeConverters.converters = converters.uniq | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
require 'fileutils' | ||
|
||
Neo4j.shutdown | ||
FileUtils.rm_rf Neo4j::Config[:storage_path] | ||
Neo4j.start | ||
# mostly copied from neo4j/spec/spec_helper | ||
|
||
EMBEDDED_DB_PATH = File.join(Dir.tmpdir, "neo4j-core-java") | ||
|
||
I18n.enforce_available_locales = false | ||
|
||
def create_session | ||
if RUBY_PLATFORM != 'java' | ||
create_server_session | ||
else | ||
require "neo4j-embedded/embedded_impermanent_session" | ||
create_embedded_session | ||
end | ||
end | ||
|
||
def create_embedded_session | ||
session = Neo4j::Session.open(:impermanent_db, EMBEDDED_DB_PATH, auto_commit: true) | ||
session.start | ||
end | ||
|
||
def create_server_session | ||
Neo4j::Session.open(:server_db, "http://localhost:7474") | ||
delete_db | ||
end | ||
|
||
FileUtils.rm_rf(EMBEDDED_DB_PATH) | ||
|
||
Dir["#{File.dirname(__FILE__)}/shared_examples/**/*.rb"].each { |f| require f } | ||
|
||
def delete_db | ||
Neo4j::Session.current._query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r') | ||
end | ||
|
||
class ActiveSupport::TestCase | ||
teardown do | ||
Neo4j.started_db.graph.getAllNodes.each do |n| | ||
Neo4j::Transaction.run do | ||
unless n.id == 0 | ||
n.rels.each { |r| r.delete unless r.nil? } | ||
n.delete unless n.nil? | ||
end | ||
end | ||
end | ||
setup do | ||
Neo4j::Session.current.close if Neo4j::Session.current | ||
create_session | ||
curr_session = Neo4j::Session.current | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,50 @@ | ||
require 'shared_user' | ||
|
||
class User < Neo4j::Rails::Model | ||
|
||
class User | ||
include Neo4j::ActiveNode | ||
include ActiveModel::Validations | ||
extend ::Devise::Models | ||
extend ::Devise::Orm::Neo4j::Hook | ||
|
||
property :username, :type => String | ||
property :facebook_token, :type => String, :index => :exact | ||
property :id | ||
|
||
property :created_at, :type => Time | ||
property :updated_at, :type => Time | ||
property :created_at, :type => DateTime | ||
property :updated_at, :type => DateTime | ||
|
||
## Database authenticatable | ||
property :email, :type => String, :null => false, :default => "", :index => :exact | ||
property :encrypted_password, :type => NilClass | ||
property :encrypted_password, :type => String | ||
|
||
## Rememberable | ||
property :remember_created_at, :type => Time | ||
property :remember_created_at, :type => DateTime | ||
|
||
## Recoverable | ||
property :reset_password_token, :type => NilClass, :index => :exact | ||
property :reset_password_sent_at, :type => Time | ||
property :reset_password_token, :type => String, :index => :exact | ||
property :reset_password_sent_at, :type => DateTime | ||
## Trackable | ||
property :sign_in_count, :type => Fixnum, :default => 0 | ||
property :current_sign_in_at, :type => Time | ||
property :last_sign_in_at, :type => Time | ||
property :current_sign_in_ip, :type => String | ||
property :last_sign_in_ip, :type => String | ||
property :sign_in_count, :type => Integer, :default => 0 | ||
property :current_sign_in_at, :type => DateTime | ||
property :last_sign_in_at, :type => DateTime | ||
property :current_sign_in_ip, :type => String | ||
property :last_sign_in_ip, :type => String | ||
|
||
## Confirmable | ||
property :confirmation_token, :type => NilClass, :index => :exact | ||
property :confirmation_token, :type => String, :index => :exact | ||
property :confirmed_at, :type => DateTime | ||
property :confirmation_sent_at, :type => DateTime | ||
|
||
## Lockable | ||
property :failed_attempts, :type => Fixnum, :default => 0 | ||
property :locked_at, :type => DateTime | ||
property :unlock_token, :type => String, :index => :exact | ||
property :failed_attempts, :type => Integer, :default => 0 | ||
property :locked_at, :type => DateTime | ||
property :unlock_token, :type => String, :index => :exact | ||
|
||
## Token authenticatable | ||
property :authentication_token, :type => String, :null => true, :index => :exact | ||
## Token authenticatable | ||
property :authentication_token, :type => String, :null => true, :index => :exact | ||
|
||
|
||
include Shim | ||
include SharedUser | ||
include Shim | ||
include SharedUser | ||
|
||
end | ||
|
||
class UserWithValidation < User | ||
validates_presence_of :username | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.