diff --git a/app/models/email_address.rb b/app/models/email_address.rb index b4e390679..2c7358c09 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, :domain_not_allowed, :domain => address.rpartition('@').last) unless self.class.valid_domain?(address) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 74067d42c..d58f14afe 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 (!, $, %, ...)" + domain_not_allowed: "contains the domain %{domain} which is not allowed" 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 b4f631997..8490ebac8 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 contains the domain black.example which is not allowed' end end @@ -147,7 +147,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest } ) assert_response :success - assert_select_error 'Email is invalid' + assert_select_error 'Email contains the domain example.fr which is not allowed' end end end