diff options
author | José Valim <jose.valim@gmail.com> | 2010-12-19 09:34:31 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-12-19 09:34:31 +0100 |
commit | 432556b9238b182dbd380a8f9936e3ca5dc6fa57 (patch) | |
tree | e6c528fb7bc49c03a605c68b3e1eedbbad10a9ca | |
parent | b8f6dd8cbb2de870a4805800fd89148a417bc612 (diff) | |
download | rails-432556b9238b182dbd380a8f9936e3ca5dc6fa57.tar.gz rails-432556b9238b182dbd380a8f9936e3ca5dc6fa57.tar.bz2 rails-432556b9238b182dbd380a8f9936e3ca5dc6fa57.zip |
Make password messages translatable.
-rw-r--r-- | activemodel/lib/active_model/locale/en.yml | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 4 | ||||
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/locale/en.yml b/activemodel/lib/active_model/locale/en.yml index 44425b4a28..c370a1f33e 100644 --- a/activemodel/lib/active_model/locale/en.yml +++ b/activemodel/lib/active_model/locale/en.yml @@ -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" diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index cd6256e3d6..cd997a61db 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -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 diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index c46a092d2d..e75bfca02a 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -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? |