提交 d592fa94 编写于 作者: J José Valim

Avoid warnings and fix small typo on SecurePassword.

上级 bd9dc4ff
......@@ -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
......
......@@ -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?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册