diff --git a/lib/devise/orm/data_mapper.rb b/lib/devise/orm/data_mapper.rb index 0b045245..0de22c70 100644 --- a/lib/devise/orm/data_mapper.rb +++ b/lib/devise/orm/data_mapper.rb @@ -79,7 +79,7 @@ module Devise def save(options=nil) if options.is_a?(Hash) && options[:validate] == false - save + save! else super() end @@ -88,10 +88,6 @@ module Devise def update_attributes(*args) update(*args) end - - def lock! - self.reload - end end end end diff --git a/lib/devise/orm/mongoid.rb b/lib/devise/orm/mongoid.rb index 6dfb40c6..0c110208 100644 --- a/lib/devise/orm/mongoid.rb +++ b/lib/devise/orm/mongoid.rb @@ -1,7 +1,6 @@ module Devise module Orm module Mongoid - module Hook def devise_modules_hook! extend Schema @@ -19,15 +18,11 @@ module Devise # Tell how to apply schema methods def apply_schema(name, type, options={}) type = Time if type == DateTime - field name, {:type => type}.merge(options) + field name, { :type => type }.merge(options) end end module Compatibility - def lock! - self.reload - end - def save(validate = true) if validate.is_a?(Hash) && validate.has_key?(:validate) validate = validate[:validate] @@ -39,9 +34,7 @@ module Devise end end -[Mongoid::Document].each do |mod| - mod::ClassMethods.class_eval do - include Devise::Models - include Devise::Orm::Mongoid::Hook - end +Mongoid::Document::ClassMethods.class_eval do + include Devise::Models + include Devise::Orm::Mongoid::Hook end \ No newline at end of file diff --git a/lib/generators/devise/templates/migration.rb b/lib/generators/devise/templates/migration.rb index 710865e4..1bbb5d75 100644 --- a/lib/generators/devise/templates/migration.rb +++ b/lib/generators/devise/templates/migration.rb @@ -1,12 +1,12 @@ class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration def self.up create_table(:<%= table_name %>) do |t| - t.database_authenticatable :encryptor => :<%= Devise.encryptor %>, :null => false + t.database_authenticatable :null => false t.confirmable t.recoverable t.rememberable t.trackable - # t.lockable + # t.lockable :unlock_strategy => :<%= Devise.unlock_strategy %> t.timestamps end diff --git a/test/integration/lockable_test.rb b/test/integration/lockable_test.rb index 45f438cb..4c85872a 100644 --- a/test/integration/lockable_test.rb +++ b/test/integration/lockable_test.rb @@ -81,7 +81,9 @@ class LockTest < ActionController::IntegrationTest test "user should not send a new e-mail if already locked" do user = create_user(:locked => true) - user.update_attribute(:failed_attempts, User.maximum_attempts + 1) + user.failed_attempts = User.maximum_attempts + 1 + user.save! + ActionMailer::Base.deliveries.clear sign_in_as_user(:password => "invalid")