Make password messages translatable.
This commit is contained in:
parent
b8f6dd8cbb
commit
432556b923
|
@ -25,3 +25,7 @@ en:
|
|||
less_than_or_equal_to: "must be less than or equal to %{count}"
|
||||
odd: "must be odd"
|
||||
even: "must be even"
|
||||
|
||||
attributes:
|
||||
password:
|
||||
unsecure: "is too weak and common"
|
||||
|
|
|
@ -63,8 +63,8 @@ module ActiveModel
|
|||
|
||||
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 too weak and common") if WEAK_PASSWORDS.include?(password)
|
||||
errors.add(:password, :too_short, :count => 7) unless password.size > 6
|
||||
errors.add(:password, :unsecure) if WEAK_PASSWORDS.include?(password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ class SecurePasswordTest < ActiveModel::TestCase
|
|||
test "too weak passwords" do
|
||||
@user.password = "012345"
|
||||
assert !@user.valid?
|
||||
assert_equal ["must be longer than 6 characters"], @user.errors[:password]
|
||||
assert_equal ["is too short (minimum is 7 characters)"], @user.errors[:password]
|
||||
|
||||
@user.password = "password"
|
||||
assert !@user.valid?
|
||||
|
|
Loading…
Reference in New Issue