Permalink
Browse files

Merge branch 'master' of git://github.com/plataformatec/devise

  • Loading branch information...
2 parents 108edb4 + 22dd5f5 commit b3f68ab287c673b2dbe4079fdfdae0e7ba864d51 @josevalim josevalim committed Oct 20, 2009
Showing with 9 additions and 8 deletions.
  1. +3 −2 lib/devise/active_record.rb
  2. +6 −6 test/models/authenticable_test.rb
@@ -3,7 +3,8 @@ module ActiveRecord
# 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 ActiveRecord
# 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:
#
@@ -3,6 +3,12 @@
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 = ''

0 comments on commit b3f68ab

Please sign in to comment.