mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Initial Datamapper test suite
Test suite runs, however there's still some failing tests. This allows us to at least have a working test suite so they can fix these datamapper spec failures individually.
This commit is contained in:
parent
afe6a8c8c8
commit
bb504e08aa
5 changed files with 65 additions and 6 deletions
9
Gemfile
9
Gemfile
|
@ -17,3 +17,12 @@ group :mongoid do
|
|||
gem "mongo_ext", ">= 0.18.3", :require => false
|
||||
gem "mongoid", :git => "git://github.com/durran/mongoid.git"
|
||||
end
|
||||
|
||||
group :data_mapper do
|
||||
gem 'do_sqlite3', '>= 0.10.1'
|
||||
gem "dm-core", :git => "git://github.com/datamapper/dm-core.git"
|
||||
|
||||
gem "dm-validations", :git => "git://github.com/datamapper/dm-more.git"
|
||||
gem "dm-timestamps", :git => "git://github.com/datamapper/dm-more.git"
|
||||
gem "dm-rails", :git => "git://github.com/datamapper/dm-rails.git"
|
||||
end
|
|
@ -38,18 +38,22 @@ module Devise
|
|||
module ClassMethods
|
||||
# Hooks for confirmable
|
||||
def before_create(*args)
|
||||
wrap_hook(:before, *args)
|
||||
wrap_hook(:before, :create, *args)
|
||||
end
|
||||
|
||||
def after_create(*args)
|
||||
wrap_hook(:after, *args)
|
||||
wrap_hook(:after, :create, *args)
|
||||
end
|
||||
|
||||
def wrap_hook(action, *args)
|
||||
def before_save(*args)
|
||||
wrap_hook(:before, :save, *args)
|
||||
end
|
||||
|
||||
def wrap_hook(action, method, *args)
|
||||
options = args.extract_options!
|
||||
|
||||
args.each do |callback|
|
||||
send action, :create, callback
|
||||
send action, method, callback
|
||||
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def #{callback}
|
||||
super if #{options[:if] || true}
|
||||
|
@ -69,9 +73,13 @@ module Devise
|
|||
end
|
||||
end
|
||||
|
||||
def changed?
|
||||
dirty?
|
||||
end
|
||||
|
||||
def save(options=nil)
|
||||
if options.is_a?(Hash) && options[:validate] == false
|
||||
save!
|
||||
save
|
||||
else
|
||||
super()
|
||||
end
|
||||
|
|
4
test/orm/data_mapper.rb
Normal file
4
test/orm/data_mapper.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
require File.expand_path('../../rails_app/config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
|
||||
DataMapper.auto_migrate!
|
17
test/rails_app/app/data_mapper/admin.rb
Normal file
17
test/rails_app/app/data_mapper/admin.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class Admin
|
||||
include DataMapper::Resource
|
||||
|
||||
property :id, Serial
|
||||
property :username, String
|
||||
|
||||
devise :authenticatable, :registerable, :timeoutable, :recoverable
|
||||
|
||||
def self.find_for_authentication(conditions)
|
||||
last(conditions)
|
||||
end
|
||||
|
||||
def self.create!(*args)
|
||||
create(*args)
|
||||
end
|
||||
|
||||
end
|
21
test/rails_app/app/data_mapper/user.rb
Normal file
21
test/rails_app/app/data_mapper/user.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
class User
|
||||
include DataMapper::Resource
|
||||
|
||||
property :id, Serial
|
||||
property :username, String
|
||||
|
||||
devise :authenticatable, :http_authenticatable, :confirmable, :lockable, :recoverable,
|
||||
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
||||
:trackable
|
||||
|
||||
# :validatable disabled for now
|
||||
timestamps :at
|
||||
|
||||
def save!(*args)
|
||||
save
|
||||
end
|
||||
|
||||
def self.create!(*args)
|
||||
create(*args)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue