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

Make password messages translatable.

上级 b8f6dd8c
...@@ -25,3 +25,7 @@ en: ...@@ -25,3 +25,7 @@ en:
less_than_or_equal_to: "must be less than or equal to %{count}" less_than_or_equal_to: "must be less than or equal to %{count}"
odd: "must be odd" odd: "must be odd"
even: "must be even" even: "must be even"
attributes:
password:
unsecure: "is too weak and common"
...@@ -63,8 +63,8 @@ def password=(unencrypted_password) ...@@ -63,8 +63,8 @@ def password=(unencrypted_password)
def password_must_be_strong def password_must_be_strong
if password.present? if password.present?
errors.add(:password, "must be longer than 6 characters") unless password.size > 6 errors.add(:password, :too_short, :count => 7) unless password.size > 6
errors.add(:password, "is too weak and common") if WEAK_PASSWORDS.include?(password) errors.add(:password, :unsecure) if WEAK_PASSWORDS.include?(password)
end end
end end
end end
......
...@@ -36,7 +36,7 @@ class SecurePasswordTest < ActiveModel::TestCase ...@@ -36,7 +36,7 @@ class SecurePasswordTest < ActiveModel::TestCase
test "too weak passwords" do test "too weak passwords" do
@user.password = "012345" @user.password = "012345"
assert !@user.valid? 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" @user.password = "password"
assert !@user.valid? assert !@user.valid?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册