diff options
Diffstat (limited to 'activemodel')
| -rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 15 | ||||
| -rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 12 |
2 files changed, 15 insertions, 12 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 879db59b34..a891d1b0c9 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -16,16 +16,19 @@ module ActiveModel # Adds methods to set and authenticate against a BCrypt password. # This mechanism requires you to have a +password_digest+ attribute. # - # Validations for presence of password on create, confirmation of password - # (using a +password_confirmation+ attribute) are automatically added. If - # you wish to turn off validations, pass <tt>validations: false</tt> as an - # argument. You can add more validations by hand if need be. + # The following validations are added automatically: + # * Password must be present on creation + # * Password length should be less than or equal to 72 characters + # * Confirmation of password (using a +password_confirmation+ attribute) # - # If you don't need the confirmation validation, just don't set any + # If validations are not needed, pass <tt>validations: false</tt> as an + # argument. More validations can be added if required. + # + # If password confirmation validation is not needed, do not set any # value to the password_confirmation attribute and the validation # will not be triggered. # - # You need to add bcrypt (~> 3.1.7) to Gemfile to use #has_secure_password: + # Add bcrypt (~> 3.1.7) to Gemfile to use #has_secure_password: # # gem 'bcrypt', '~> 3.1.7' # diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index 40a5de3367..e59f00c8c5 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -92,15 +92,15 @@ class SecurePasswordTest < ActiveModel::TestCase end test "update an existing user with validations and valid password/confirmation" do - @user.password = 'password' - @user.password_confirmation = 'password' + @existing_user.password = 'password' + @existing_user.password_confirmation = 'password' - assert @user.valid?(:update), 'user should be valid' + assert @existing_user.valid?(:update), 'user should be valid' - @user.password = 'a' * 72 - @user.password_confirmation = 'a' * 72 + @existing_user.password = 'a' * 72 + @existing_user.password_confirmation = 'a' * 72 - assert @user.valid?(:update), 'user should be valid' + assert @existing_user.valid?(:update), 'user should be valid' end test "updating an existing user with validation and a blank password" do |
