Make password messages translatable.

This commit is contained in:
José Valim 2010-12-19 09:34:31 +01:00
parent b8f6dd8cbb
commit 432556b923
3 changed files with 7 additions and 3 deletions

View File

@ -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"

View File

@ -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

View File

@ -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?