end
def validate_email_domain
- errors.add(:address, :invalid) unless self.class.valid_domain?(address)
+ domain = address.partition('@').last
+ return if self.class.valid_domain?(domain)
+
+ if User.current.logged?
+ errors.add(:address, :domain_not_allowed, :domain => domain)
+ else
+ # Don't display a detailed error message for anonymous users
+ errors.add(:address, :invalid)
+ end
end
end
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 a domain not allowed (%{domain})"
actionview_instancetag_blank_option: Please select
}
)
assert_response :success
- assert_select_error 'Email is invalid'
+ assert_select_error 'Email contains a domain not allowed (black.example)'
end
end
}
)
assert_response :success
- assert_select_error 'Email is invalid'
+ assert_select_error 'Email contains a domain not allowed (example.fr)'
end
end
end