1
0
Fork 0
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:
Jacques Crocker 2010-03-27 16:15:23 -07:00
parent afe6a8c8c8
commit bb504e08aa
5 changed files with 65 additions and 6 deletions

View file

@ -16,4 +16,13 @@ group :mongoid do
gem "mongo", ">= 0.18.3"
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

View file

@ -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 before_save(*args)
wrap_hook(:before, :save, *args)
end
def wrap_hook(action, *args)
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}
@ -68,10 +72,14 @@ module Devise
end
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
View file

@ -0,0 +1,4 @@
require File.expand_path('../../rails_app/config/environment', __FILE__)
require 'rails/test_help'
DataMapper.auto_migrate!

View 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

View 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