diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-03-04 18:56:05 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-03-04 18:56:05 +0100 |
commit | 8c1687bbf8dd518d64fc7180b33c1cb57f29a69a (patch) | |
tree | 17538b7a80d65742b6872f7b1fef5122c324060b /activemodel/test | |
parent | b501ee47fa3f877f8b8028e732f8ef8a22cc75fb (diff) | |
download | rails-8c1687bbf8dd518d64fc7180b33c1cb57f29a69a.tar.gz rails-8c1687bbf8dd518d64fc7180b33c1cb57f29a69a.tar.bz2 rails-8c1687bbf8dd518d64fc7180b33c1cb57f29a69a.zip |
`has_secure_password` is not invalid when assigning empty Strings.
Closes #9535.
With 692b3b6 the `password=` setter does no longer set blank passwords.
This triggered validation errors when assigning empty Strings to `password`
and `password_confirmation`.
This patch only sets the confirmation if it is not `blank?`.
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index 7783bb25d5..02cd3b8a93 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -88,4 +88,10 @@ class SecurePasswordTest < ActiveModel::TestCase @user.password = "secret" assert_equal BCrypt::Engine::MIN_COST, @user.password_digest.cost end + + test "blank password_confirmation does not result in a confirmation error" do + @user.password = "" + @user.password_confirmation = "" + assert @user.valid?(:update), "user should be valid" + end end |