Skip to content

Commit

Permalink
Make password messages translatable.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 19, 2010
1 parent b8f6dd8 commit 432556b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions activemodel/lib/active_model/locale/en.yml
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions activemodel/lib/active_model/secure_password.rb
Expand Up @@ -63,8 +63,8 @@ def password=(unencrypted_password)

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
Expand Down
2 changes: 1 addition & 1 deletion activemodel/test/cases/secure_password_test.rb
Expand Up @@ -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?
Expand Down

0 comments on commit 432556b

Please sign in to comment.