diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-12-01 16:04:40 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-12-01 16:04:40 +0000 |
commit | 04616522ace7f777dadf209b86d7e97ea97379ed (patch) | |
tree | 7eeb964d15ceb6f9ec280487a4c79d720ed90f58 | |
parent | c2ffe3ef2904b07d8fcc0517c8d326e2e4105865 (diff) |
Fix for interpolation bug introduced in 7a3b462f41321034cbdd2c83707f739a442e83c6.
The string with the unsubstituted variable pattern was being made
available for translation, instead of the translatable version.
-rw-r--r-- | app/models/change_email_validator.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index 7ee6654bb..65f2fd81c 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -55,10 +55,20 @@ class ChangeEmailValidator def check_email_is_present_and_valid(email) if !send(email).blank? && !MySociety::Validate.is_valid_email(send(email)) - errors.add(email, _("#{ email.to_s.humanize } doesn't look like a valid address")) + msg_string = check_email_is_present_and_valid_msg_string(email) + errors.add(email, msg_string) end end + def check_email_is_present_and_valid_msg_string(email) + case email.to_sym + when :old_email then _("Old email doesn't look like a valid address") + when :new_email then _("New email doesn't look like a valid address") + else + raise "Unsupported email type #{ email }" + end + end + def email_belongs_to_user?(email) email.downcase == logged_in_user.email.downcase end |