diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-07-06 20:21:58 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-07-06 20:21:58 +0300 |
commit | 382b5ca7dda7ee6e4c0adebfda767db6acc407d2 (patch) | |
tree | 7abc739f5e64b286a5a10239f9f873bde9d8588a | |
parent | 73a9f64091e49ad1db9f683422943326b531652f (diff) | |
download | rails-382b5ca7dda7ee6e4c0adebfda767db6acc407d2.tar.gz rails-382b5ca7dda7ee6e4c0adebfda767db6acc407d2.tar.bz2 rails-382b5ca7dda7ee6e4c0adebfda767db6acc407d2.zip |
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`.
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index bc23316ad5..327661a9ca 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -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 |