mirror of https://github.com/rails/rails
Improve `SecurePasswordTest#test_authenticate`
- Ensure that execution of `authenticate`/`authenticate_XXX` returns `self` if password is correct, otherwise `false` (as mentioned in the documentation). - Test `authenticate_password`.
This commit is contained in:
parent
73a9f64091
commit
382b5ca7dd
|
@ -188,11 +188,14 @@ class SecurePasswordTest < ActiveModel::TestCase
|
|||
@user.password = "secret"
|
||||
@user.activation_token = "new_token"
|
||||
|
||||
assert_not @user.authenticate("wrong")
|
||||
assert @user.authenticate("secret")
|
||||
assert_equal false, @user.authenticate("wrong")
|
||||
assert_equal @user, @user.authenticate("secret")
|
||||
|
||||
assert !@user.authenticate_activation_token("wrong")
|
||||
assert @user.authenticate_activation_token("new_token")
|
||||
assert_equal false, @user.authenticate_password("wrong")
|
||||
assert_equal @user, @user.authenticate_password("secret")
|
||||
|
||||
assert_equal false, @user.authenticate_activation_token("wrong")
|
||||
assert_equal @user, @user.authenticate_activation_token("new_token")
|
||||
end
|
||||
|
||||
test "Password digest cost defaults to bcrypt default cost when min_cost is false" do
|
||||
|
|
Loading…
Reference in New Issue