devise-active_node 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +17 -0
- data/Rakefile +15 -0
- data/devise-active_node.gemspec +27 -0
- data/lib/devise/active_node/models.rb +44 -0
- data/lib/devise/active_node/version.rb +5 -0
- data/lib/devise/active_node.rb +12 -0
- data/lib/devise/orm/active_node.rb +4 -0
- data/lib/orm_adapter/adapters/active_node.rb +50 -0
- data/spec/orm_adapter/adapters/active_node_spec.rb +32 -0
- data/spec/orm_adapter/example_app_shared.rb +240 -0
- data/spec/spec_helper.rb +17 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74a1cabda42e11e0c77a6fbdf3a12856a07e6288
|
4
|
+
data.tar.gz: 51f194c4e6a4e0f06dff905968414fa40c11cbff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f74338d8b22b54c8824a5eb6ed6f673a65bb2d80de5b4f084aa0a45885c209fd77b169f8f0f5a11f8b9a9ff9f1c791d4b38f8afa0692acdb3899f9bdb5d4786c
|
7
|
+
data.tar.gz: accfa476762d9fcaeaa588066d4776dfff00d7330a213e7e953a79986528f7560ba6b7bedab982cf982072989e85fa18afcd250ddad87b93133ed72abb81b5f2
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
neo4j
|
24
|
+
.idea
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Heinrich Klobuczek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# ActiveNode ORM for Devise
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add devise-active_node to your Gemfile
|
6
|
+
|
7
|
+
gem 'devise-active_node'
|
8
|
+
|
9
|
+
Comment out the current ORM in config/initializers/devise.rb, and add:
|
10
|
+
|
11
|
+
require 'devise/orm/active_node'
|
12
|
+
|
13
|
+
Configure your model:
|
14
|
+
|
15
|
+
class User < ActiveNode::Base
|
16
|
+
devise :registerable, :database_authenticatable, :recoverable
|
17
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
require "bundler/gem_tasks"
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
require 'neography/tasks'
|
11
|
+
|
12
|
+
task :default => :spec
|
13
|
+
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
15
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'devise/active_node/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "devise-active_node"
|
8
|
+
spec.version = Devise::ActiveNode::VERSION
|
9
|
+
spec.authors = ["Heinrich Klobuczek"]
|
10
|
+
spec.email = ["heinrich@mail.com"]
|
11
|
+
spec.summary = 'ActiveNode ORM for devise'
|
12
|
+
spec.description = 'Adapter to enable usage of devise with ActiveNode'
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "active_node", ">= 2.2.0"
|
22
|
+
spec.add_dependency "devise"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec", ">= 2.4.0"
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Devise
|
2
|
+
module ActiveNode
|
3
|
+
module Models
|
4
|
+
include Devise::Models
|
5
|
+
|
6
|
+
def devise(*modules)
|
7
|
+
modules.each do |m|
|
8
|
+
case m
|
9
|
+
when :database_authenticatable
|
10
|
+
attribute :email, type: String
|
11
|
+
attribute :encrypted_password, type: String
|
12
|
+
|
13
|
+
when :recoverable
|
14
|
+
attribute :reset_password_token, type: String
|
15
|
+
attribute :reset_password_sent_at
|
16
|
+
|
17
|
+
when :rememberable
|
18
|
+
attribute :remember_created_at
|
19
|
+
|
20
|
+
when :trackable
|
21
|
+
attribute :sign_in_count, type: Integer
|
22
|
+
attribute :current_sign_in_at
|
23
|
+
attribute :last_sign_in_at
|
24
|
+
attribute :current_sign_in_ip, type: String
|
25
|
+
attribute :last_sign_in_ip, type: String
|
26
|
+
|
27
|
+
when :confirmable
|
28
|
+
attribute :confirmation_token, type: String
|
29
|
+
attribute :confirmed_at
|
30
|
+
attribute :confirmation_sent_at
|
31
|
+
attribute :unconfirmed_email, type: String # Only if using reconfirmable
|
32
|
+
|
33
|
+
when :lockable
|
34
|
+
attribute :failed_attempts, type: Integer # Only if lock strategy is :failed_attempts
|
35
|
+
attribute :unlock_token, type: String # Only if unlock strategy is :email or :both
|
36
|
+
attribute :locked_at
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
super(*modules)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "active_support/dependencies/autoload"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module ActiveNode
|
5
|
+
extend ActiveSupport::Autoload
|
6
|
+
autoload :VERSION
|
7
|
+
autoload :Models
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# puts '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
|
12
|
+
# require 'orm_adapter/adapters/active_node'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'active_node'
|
2
|
+
|
3
|
+
module OrmAdapter
|
4
|
+
class ActiveNode < Base
|
5
|
+
# Return list of column/property names
|
6
|
+
def column_names
|
7
|
+
klass.attribute_names
|
8
|
+
end
|
9
|
+
|
10
|
+
# @see OrmAdapter::Base#get!
|
11
|
+
def get!(id)
|
12
|
+
klass.find(wrap_key(id))
|
13
|
+
end
|
14
|
+
|
15
|
+
# @see OrmAdapter::Base#get
|
16
|
+
def get(id)
|
17
|
+
find_first(id: wrap_key(id))
|
18
|
+
end
|
19
|
+
|
20
|
+
# @see OrmAdapter::Base#find_first
|
21
|
+
def find_first(options = {})
|
22
|
+
find_all(options).first
|
23
|
+
end
|
24
|
+
|
25
|
+
# @see OrmAdapter::Base#find_all
|
26
|
+
def find_all(options = {})
|
27
|
+
klass
|
28
|
+
.order(options.delete :order)
|
29
|
+
.where(options.delete :conditions)
|
30
|
+
.limit(options.delete :limit)
|
31
|
+
.offset(options.delete :offset)
|
32
|
+
.where(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @see OrmAdapter::Base#create!
|
36
|
+
def create!(attributes = {})
|
37
|
+
klass.create!(attributes)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @see OrmAdapter::Base#destroy
|
41
|
+
def destroy(object)
|
42
|
+
object.destroy && true if valid_object?(object)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
ActiveSupport.on_load(:active_node) do
|
48
|
+
extend ::OrmAdapter::ToAdapter
|
49
|
+
self::OrmAdapter = ::OrmAdapter::ActiveNode
|
50
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'orm_adapter/example_app_shared'
|
3
|
+
|
4
|
+
if !defined?(ActiveNode::Base)
|
5
|
+
puts "** require 'active_node' to run the specs in #{__FILE__}"
|
6
|
+
else
|
7
|
+
module ArOrmSpec
|
8
|
+
class User < ActiveNode::Base
|
9
|
+
attribute :name, type: String
|
10
|
+
attribute :rating, type: Integer
|
11
|
+
|
12
|
+
has_many :notes, type: :owner, direction: :incoming
|
13
|
+
end
|
14
|
+
|
15
|
+
class Note < ActiveNode::Base
|
16
|
+
has_one :owner, class_name: 'ArOrmSpec::User'
|
17
|
+
end
|
18
|
+
|
19
|
+
# here be the specs!
|
20
|
+
describe '[ActiveNode orm adapter]' do
|
21
|
+
before do
|
22
|
+
User.delete_all
|
23
|
+
Note.delete_all
|
24
|
+
end
|
25
|
+
|
26
|
+
it_should_behave_like "example app with orm_adapter" do
|
27
|
+
let(:user_class) { User }
|
28
|
+
let(:note_class) { Note }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
# to test your new orm_adapter, make an example app that matches the functionality
|
2
|
+
# found in the existing specs for example, look at spec/orm_adapter/adapters/active_record_spec.rb
|
3
|
+
#
|
4
|
+
# Then you can execute this shared spec as follows:
|
5
|
+
#
|
6
|
+
# it_should_behave_like "execute app with orm_adapter" do
|
7
|
+
# let(:user_class) { User }
|
8
|
+
# let(:note_class) { Note }
|
9
|
+
#
|
10
|
+
# # optionaly define the following functions if the ORM does not support
|
11
|
+
# # this syntax - this should NOT use the orm_adapter, because we're testing that
|
12
|
+
# def create_model(klass, attrs = {})
|
13
|
+
# klass.create!(attrs)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def reload_model(model)
|
17
|
+
# model.class.find(model.id)
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
shared_examples_for "example app with orm_adapter" do
|
22
|
+
|
23
|
+
def create_model(klass, attrs = {})
|
24
|
+
klass.create!(attrs)
|
25
|
+
end
|
26
|
+
|
27
|
+
def reload_model(model)
|
28
|
+
model.class.find(model.id)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "an ORM class" do
|
32
|
+
subject { note_class }
|
33
|
+
|
34
|
+
it "#to_adapter should return an adapter instance" do
|
35
|
+
subject.to_adapter.should be_a(OrmAdapter::Base)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "#to_adapter should return an adapter for the receiver" do
|
39
|
+
subject.to_adapter.klass.should == subject
|
40
|
+
end
|
41
|
+
|
42
|
+
it "#to_adapter should be cached" do
|
43
|
+
subject.to_adapter.object_id.should == subject.to_adapter.object_id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "adapter instance" do
|
48
|
+
let(:note_adapter) { note_class.to_adapter }
|
49
|
+
let(:user_adapter) { user_class.to_adapter }
|
50
|
+
|
51
|
+
describe "#get!(id)" do
|
52
|
+
it "should return the instance with id if it exists" do
|
53
|
+
user = create_model(user_class)
|
54
|
+
user_adapter.get!(user.id).should == user
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should allow to_key like arguments" do
|
58
|
+
user = create_model(user_class)
|
59
|
+
user_adapter.get!(user.to_key).should == user
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should raise an error if there is no instance with that id" do
|
63
|
+
lambda { user_adapter.get!("nonexistent id") }.should raise_error
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#get(id)" do
|
68
|
+
it "should return the instance with id if it exists" do
|
69
|
+
user = create_model(user_class)
|
70
|
+
user_adapter.get(user.id).should == user
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should allow to_key like arguments" do
|
74
|
+
user = create_model(user_class)
|
75
|
+
user_adapter.get(user.to_key).should == user
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return nil if there is no instance with that id" do
|
79
|
+
user_adapter.get("nonexistent id").should be_nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#find_first" do
|
84
|
+
describe "(conditions)" do
|
85
|
+
it "should return first model matching conditions, if it exists" do
|
86
|
+
user = create_model(user_class, :name => "Fred")
|
87
|
+
user_adapter.find_first(:name => "Fred").should == user
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should return nil if no conditions match" do
|
91
|
+
user_adapter.find_first(:name => "Betty").should == nil
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should return the first model if no conditions passed' do
|
95
|
+
user = create_model(user_class)
|
96
|
+
create_model(user_class)
|
97
|
+
user_adapter.find_first.should == user
|
98
|
+
end
|
99
|
+
|
100
|
+
it "when conditions contain associated object, should return first model if it exists" do
|
101
|
+
user = create_model(user_class)
|
102
|
+
note = create_model(note_class, :owner => user)
|
103
|
+
note_adapter.find_first(:owner => user).should == note
|
104
|
+
end
|
105
|
+
|
106
|
+
it "understands :id as a primary key condition (allowing scoped finding)" do
|
107
|
+
create_model(user_class, :name => "Fred")
|
108
|
+
user = create_model(user_class, :name => "Fred")
|
109
|
+
user_adapter.find_first(:id => user.id, :name => "Fred").should == user
|
110
|
+
user_adapter.find_first(:id => user.id, :name => "Not Fred").should be_nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "(:order => <order array>)" do
|
115
|
+
it "should return first model in specified order" do
|
116
|
+
user1 = create_model(user_class, :name => "Fred", :rating => 1)
|
117
|
+
user2 = create_model(user_class, :name => "Fred", :rating => 2)
|
118
|
+
user_adapter.find_first(:order => [:name, [:rating, :desc]]).should == user2
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "(:conditions => <conditions hash>, :order => <order array>)" do
|
123
|
+
it "should return first model matching conditions, in specified order" do
|
124
|
+
user1 = create_model(user_class, :name => "Fred", :rating => 1)
|
125
|
+
user2 = create_model(user_class, :name => "Fred", :rating => 2)
|
126
|
+
user_adapter.find_first(:conditions => {:name => "Fred"}, :order => [:rating, :desc]).should == user2
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "#find_all" do
|
132
|
+
describe "(conditions)" do
|
133
|
+
it "should return only models matching conditions" do
|
134
|
+
user1 = create_model(user_class, :name => "Fred")
|
135
|
+
user2 = create_model(user_class, :name => "Fred")
|
136
|
+
user3 = create_model(user_class, :name => "Betty")
|
137
|
+
user_adapter.find_all(:name => "Fred").should == [user1, user2]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should return all models if no conditions passed" do
|
141
|
+
user1 = create_model(user_class, :name => "Fred")
|
142
|
+
user2 = create_model(user_class, :name => "Fred")
|
143
|
+
user3 = create_model(user_class, :name => "Betty")
|
144
|
+
user_adapter.find_all.should == [user1, user2, user3]
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should return empty array if no conditions match" do
|
148
|
+
user_adapter.find_all(:name => "Fred").should == []
|
149
|
+
end
|
150
|
+
|
151
|
+
it "when conditions contain associated object, should return first model if it exists" do
|
152
|
+
user1, user2 = create_model(user_class), create_model(user_class)
|
153
|
+
note1 = create_model(note_class, :owner => user1)
|
154
|
+
note2 = create_model(note_class, :owner => user2)
|
155
|
+
note_adapter.find_all(:owner => user2).should == [note2]
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "(:order => <order array>)" do
|
160
|
+
it "should return all models in specified order" do
|
161
|
+
user1 = create_model(user_class, :name => "Fred", :rating => 1)
|
162
|
+
user2 = create_model(user_class, :name => "Fred", :rating => 2)
|
163
|
+
user3 = create_model(user_class, :name => "Betty", :rating => 1)
|
164
|
+
user_adapter.find_all(:order => [:name, [:rating, :desc]]).should == [user3, user2, user1]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "(:conditions => <conditions hash>, :order => <order array>)" do
|
169
|
+
it "should return only models matching conditions, in specified order" do
|
170
|
+
user1 = create_model(user_class, :name => "Fred", :rating => 1)
|
171
|
+
user2 = create_model(user_class, :name => "Fred", :rating => 2)
|
172
|
+
user3 = create_model(user_class, :name => "Betty", :rating => 1)
|
173
|
+
user_adapter.find_all(:conditions => {:name => "Fred"}, :order => [:rating, :desc]).should == [user2, user1]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "(:limit => <number of items>)" do
|
178
|
+
it "should return a limited set of matching models" do
|
179
|
+
user1 = create_model(user_class, :name => "Fred", :rating => 1)
|
180
|
+
user2 = create_model(user_class, :name => "Fred", :rating => 2)
|
181
|
+
user3 = create_model(user_class, :name => "Betty", :rating => 1)
|
182
|
+
user_adapter.find_all(:limit => 1).should == [user1]
|
183
|
+
user_adapter.find_all(:limit => 2).should == [user1, user2]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "(:offset => <offset number>) with limit (as DataMapper doesn't allow offset on its own)" do
|
188
|
+
it "should return an offset set of matching models" do
|
189
|
+
user1 = create_model(user_class, :name => "Fred", :rating => 1)
|
190
|
+
user2 = create_model(user_class, :name => "Fred", :rating => 2)
|
191
|
+
user3 = create_model(user_class, :name => "Betty", :rating => 1)
|
192
|
+
user_adapter.find_all(:limit => 3, :offset => 0).should == [user1, user2, user3]
|
193
|
+
user_adapter.find_all(:limit => 3, :offset => 1).should == [user2, user3]
|
194
|
+
user_adapter.find_all(:limit => 1, :offset => 1).should == [user2]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "#create!(attributes)" do
|
200
|
+
it "should create a model with the passed attributes" do
|
201
|
+
user = user_adapter.create!(:name => "Fred")
|
202
|
+
reload_model(user).name.should == "Fred"
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should raise error when create fails" do
|
206
|
+
lambda { user_adapter.create!(:user => create_model(note_class)) }.should raise_error
|
207
|
+
end
|
208
|
+
|
209
|
+
it "when attributes contain an associated object, should create a model with the attributes" do
|
210
|
+
user = create_model(user_class)
|
211
|
+
note = note_adapter.create!(:owner => user)
|
212
|
+
reload_model(note).owner.should == user
|
213
|
+
end
|
214
|
+
|
215
|
+
it "when attributes contain an has_many assoc, should create a model with the attributes" do
|
216
|
+
notes = [create_model(note_class), create_model(note_class)]
|
217
|
+
user = user_adapter.create!(:notes => notes)
|
218
|
+
reload_model(user).notes.should == notes
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "#destroy(instance)" do
|
223
|
+
it "should destroy the instance if it exists" do
|
224
|
+
user = create_model(user_class)
|
225
|
+
user_adapter.destroy(user).should be_true
|
226
|
+
user_adapter.get(user.id).should be_nil
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should return nil if passed with an invalid instance" do
|
230
|
+
user_adapter.destroy("nonexistent instance").should be_nil
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should not destroy the instance if it doesn't match the model class" do
|
234
|
+
user = create_model(user_class)
|
235
|
+
note_adapter.destroy(user).should be_nil
|
236
|
+
user_adapter.get(user.id).should == user
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
5
|
+
|
6
|
+
['active_node'].each do |orm|
|
7
|
+
begin
|
8
|
+
require orm
|
9
|
+
rescue LoadError
|
10
|
+
puts "#{orm} not available"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# require 'devise/active_node'
|
15
|
+
require 'neography'
|
16
|
+
require 'orm_adapter'
|
17
|
+
require 'orm_adapter/adapters/active_node'
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise-active_node
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Heinrich Klobuczek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: active_node
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: devise
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.4.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.4.0
|
83
|
+
description: Adapter to enable usage of devise with ActiveNode
|
84
|
+
email:
|
85
|
+
- heinrich@mail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- devise-active_node.gemspec
|
97
|
+
- lib/devise/active_node.rb
|
98
|
+
- lib/devise/active_node/models.rb
|
99
|
+
- lib/devise/active_node/version.rb
|
100
|
+
- lib/devise/orm/active_node.rb
|
101
|
+
- lib/orm_adapter/adapters/active_node.rb
|
102
|
+
- spec/orm_adapter/adapters/active_node_spec.rb
|
103
|
+
- spec/orm_adapter/example_app_shared.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
homepage: ''
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.3.1
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.2.2
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: ActiveNode ORM for devise
|
129
|
+
test_files:
|
130
|
+
- spec/orm_adapter/adapters/active_node_spec.rb
|
131
|
+
- spec/orm_adapter/example_app_shared.rb
|
132
|
+
- spec/spec_helper.rb
|