diff --git a/lib/devise/active_record.rb b/lib/devise/active_record.rb index f6bd79bc..a59431e9 100644 --- a/lib/devise/active_record.rb +++ b/lib/devise/active_record.rb @@ -3,7 +3,8 @@ module Devise # Shortcut method for including all devise modules inside your model. # You can give some extra options while declaring devise in your model: # - # * except: let's you add all devise modules, except the ones you setup here: + # * except: convenient option that allows you to add all devise modules, + # removing only the modules you setup here: # # devise :all, :except => :rememberable # @@ -17,7 +18,7 @@ module Devise # devise :all, :stretches => 20 # # You can refer to Authenticable for more information about writing your own - # method to setup pepper and stretches + # method to setup pepper and stretches. # # Examples: # diff --git a/test/models/authenticable_test.rb b/test/models/authenticable_test.rb index fcf392fd..8e609468 100644 --- a/test/models/authenticable_test.rb +++ b/test/models/authenticable_test.rb @@ -3,6 +3,12 @@ require 'digest/sha1' class AuthenticableTest < ActiveSupport::TestCase + def encrypt_password(user, pepper=nil, stretches=1) + user.class_eval { define_method(:stretches) { stretches } } if stretches + user.password = '123456' + ::Digest::SHA1.hexdigest("--#{user.password_salt}--#{pepper}--123456--#{pepper}--") + end + test 'should respond to password and password confirmation' do user = new_user assert user.respond_to?(:password) @@ -78,12 +84,6 @@ class AuthenticableTest < ActiveSupport::TestCase assert_equal encrypt_password(user), user.encrypted_password end - def encrypt_password(user, pepper=nil, stretches=1) - user.instance_variable_set(:@stretches, stretches) if stretches - user.password = '123456' - ::Digest::SHA1.hexdigest("--#{user.password_salt}--#{pepper}--123456--#{pepper}--") - end - test 'should fallback to devise pepper default configuring' do begin Devise.pepper = ''