From 382b5ca7dda7ee6e4c0adebfda767db6acc407d2 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Fri, 6 Jul 2018 20:21:58 +0300 Subject: 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`. --- activemodel/test/cases/secure_password_test.rb | 11 +++++++---- 1 file 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 -- cgit v1.2.3