From 8893d711e0214fee3272bcc3bdf01bbd74357c44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9gis=20Hanol?= <regis@hanol.fr>
Date: Wed, 17 Feb 2016 11:25:49 +0100
Subject: [PATCH] FEATURE: new pop3 polling configuration admin dashboard check

---
 app/models/admin_dashboard_data.rb                       | 7 ++++++-
 lib/validators/pop3_polling_enabled_setting_validator.rb | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb
index 5cfa8bea2c9..e2a130053ae 100644
--- a/app/models/admin_dashboard_data.rb
+++ b/app/models/admin_dashboard_data.rb
@@ -62,7 +62,8 @@ class AdminDashboardData
                       :failing_emails_check, :default_logo_check, :contact_email_check,
                       :send_consumer_email_check, :title_check,
                       :site_description_check, :site_contact_username_check,
-                      :notification_email_check, :subfolder_ends_in_slash_check
+                      :notification_email_check, :subfolder_ends_in_slash_check,
+                      :pop3_polling_configuration
 
     add_problem_check do
       sidekiq_check || queue_size_check
@@ -205,4 +206,8 @@ class AdminDashboardData
     I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/
   end
 
+  def pop3_polling_configuration
+    POP3PollingEnabledSettingValidator.new.error_message if SiteSetting.pop3_polling_enabled
+  end
+
 end
diff --git a/lib/validators/pop3_polling_enabled_setting_validator.rb b/lib/validators/pop3_polling_enabled_setting_validator.rb
index adee3dfc5df..f62e252bbbe 100644
--- a/lib/validators/pop3_polling_enabled_setting_validator.rb
+++ b/lib/validators/pop3_polling_enabled_setting_validator.rb
@@ -23,7 +23,7 @@ class POP3PollingEnabledSettingValidator
       I18n.t("site_settings.errors.pop3_polling_username_is_empty")
     elsif SiteSetting.pop3_polling_password.blank?
       I18n.t("site_settings.errors.pop3_polling_password_is_empty")
-    else
+    elsif !authentication_works?
       I18n.t("site_settings.errors.pop3_polling_authentication_failed")
     end
   end