Bring password_digest back.

This method is part of the protected API and is used by custom
encryption engines (like `devise-encryptable`) to hook the custom
encryption logic in the models.

Fixes #2730
This commit is contained in:
Lucas Mazza
2013-11-08 16:22:31 -02:00
parent e26ea51fe5
commit bf5bcd52cb
3 changed files with 22 additions and 1 deletions

View File

@@ -93,6 +93,11 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
assert_present user.encrypted_password
end
test 'should support custom encryption methods' do
user = UserWithCustomEncryption.new(:password => '654321')
assert_equal user.encrypted_password, '123456'
end
test 'allow authenticatable_salt to work even with nil encrypted password' do
user = User.new
user.encrypted_password = nil

View File

@@ -12,6 +12,13 @@ class UserWithValidation < User
validates_presence_of :username
end
class UserWithCustomEncryption < User
protected
def password_digest(password)
password.reverse
end
end
class UserWithVirtualAttributes < User
devise :case_insensitive_keys => [ :email, :email_confirmation ]
validates :email, :presence => true, :confirmation => {:on => :create}