diff --git a/app/models/email_address.rb b/app/models/email_address.rb index d031327dbb..9d13561c48 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -143,6 +143,6 @@ class EmailAddress < ActiveRecord::Base end def validate_email_domain - errors.add(:address, :invalid) unless self.class.valid_domain?(address) + errors.add(:address, :not_allow_domain, :domain => address.split('@').last) unless self.class.valid_domain?(address) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 0aeafe516b..8d93847344 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -136,6 +136,7 @@ en: must_contain_lowercase: "must contain lowercase letters (a-z)" must_contain_digits: "must contain digits (0-9)" must_contain_special_chars: "must contain special characters (!, $, %, ...)" + not_allow_domain: "does not allow domain %{domain}" actionview_instancetag_blank_option: Please select diff --git a/test/functional/email_addresses_controller_test.rb b/test/functional/email_addresses_controller_test.rb index 5984cf8868..ea9cb7b1d3 100644 --- a/test/functional/email_addresses_controller_test.rb +++ b/test/functional/email_addresses_controller_test.rb @@ -131,7 +131,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest } ) assert_response :success - assert_select_error 'Email is invalid' + assert_select_error 'Email does not allow domain black.example' end end @@ -147,7 +147,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest } ) assert_response :success - assert_select_error 'Email is invalid' + assert_select_error 'Email does not allow domain example.fr' end end end