Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid warnings and fix small typo on SecurePassword.

  • Loading branch information...
commit d592fa946d43fdadf23f872a5c3334fb4f108f80 1 parent bd9dc4f
@josevalim josevalim authored
View
6 activemodel/lib/active_model/secure_password.rb
@@ -62,9 +62,9 @@ def password=(unencrypted_password)
private
def password_must_be_strong
- if @password.present?
- errors.add(:password, "must be longer than 6 characters") unless @password.size > 6
- errors.add(:password, "is a too weak and common") if WEAK_PASSWORDS.include?(@password)
+ if password.present?
+ errors.add(:password, "must be longer than 6 characters") unless password.size > 6
+ errors.add(:password, "is too weak and common") if WEAK_PASSWORDS.include?(password)
end
end
end
View
4 activemodel/test/cases/secure_password_test.rb
@@ -34,11 +34,13 @@ class SecurePasswordTest < ActiveModel::TestCase
end
test "too weak passwords" do
- @user.password = "123456"
+ @user.password = "012345"
assert !@user.valid?
+ assert_equal ["must be longer than 6 characters"], @user.errors[:password]
@user.password = "password"
assert !@user.valid?
+ assert_equal ["is too weak and common"], @user.errors[:password]
@user.password = "d9034rfjlakj34RR$!!"
assert @user.valid?
Please sign in to comment.
Something went wrong with that request. Please try again.