diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb index b28a6227348..c5375311245 100644 --- a/app/models/admin_dashboard_data.rb +++ b/app/models/admin_dashboard_data.rb @@ -32,6 +32,7 @@ class AdminDashboardData failing_emails_check, default_logo_check, contact_email_check, + send_email_with_gmail_check, title_check ].compact end @@ -120,4 +121,8 @@ class AdminDashboardData I18n.t('dashboard.title_nag') if SiteSetting.title == SiteSetting.defaults[:title] end + def send_email_with_gmail_check + I18n.t('dashboard.gmail_for_email_warning') if Rails.env == 'production' and ActionMailer::Base.smtp_settings[:address] =~ /gmail\.com/ + end + end \ No newline at end of file diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 81b61a68405..ca87c29a7b2 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -373,9 +373,9 @@ en: dashboard: rails_env_warning: "Your server is running in %{env} mode." host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname." - gc_warning: 'Your server is using default ruby garbage collection parameters, which will not give you the best performance. Read this topic on performance tuning: Tuning Ruby and Rails for Discourse.' - clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. Learn about clockwork here.' - sidekiq_warning: 'Sidekiq is not running. Many tasks, like sending emails, are executed asynchronously by sidekiq. Please ensure at least one sidekiq process is running. Learn about Sidekiq here.' + gc_warning: 'Your server is using default ruby garbage collection parameters, which will not give you the best performance. Read this topic on performance tuning: Tuning Ruby and Rails for Discourse.' + clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. Learn about clockwork here.' + sidekiq_warning: 'Sidekiq is not running. Many tasks, like sending emails, are executed asynchronously by sidekiq. Please ensure at least one sidekiq process is running. Learn about Sidekiq here.' queue_size_warning: 'The number of queued jobs is %{queue_size}, which is high. This could indicate a problem with the Sidekiq process(es), or you may need to add more Sidekiq workers.' memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.' facebook_config_warning: 'The server is configured to allow signup and log in with Facebook (enable_facebook_logins), but the app id and app secret values are not set. Go to the Site Settings and update the settings. See this guide to learn more.' @@ -387,6 +387,7 @@ en: contact_email_missing: "You haven't provided a contact email for your site. Please update contact_email in the Site Settings." contact_email_invalid: "The site contact email is invalid. Please update contact_email in the Site Settings." title_nag: "The title Site Setting is still set to the default value. Please update it with your site's title in the Site Settings." + gmail_for_email_warning: "Your site is configured to use Gmail to send email. Gmail limits how many emails you can send. Consider using an email service provider to ensure email deliverability." content_types: education_new_reply: diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb index 03846b9f8a7..d52e079ae02 100644 --- a/spec/models/admin_dashboard_data_spec.rb +++ b/spec/models/admin_dashboard_data_spec.rb @@ -121,9 +121,32 @@ describe AdminDashboardData do end end + describe 'send_email_with_gmail_check' do + subject { AdminDashboardData.new.send_email_with_gmail_check } + + it 'returns nil if gmail.com is not in the smtp_settings address' do + ActionMailer::Base.stubs(:smtp_settings).returns({address: 'mandrillapp.com'}) + expect(subject).to be_nil + end + + context 'gmail.com is in the smtp_settings address' do + before { ActionMailer::Base.stubs(:smtp_settings).returns({address: 'smtp.gmail.com'}) } + + it 'returns nil in development env' do + Rails.stubs(:env).returns('development') + expect(subject).to be_nil + end + + it 'returns a string when in production env' do + Rails.stubs(:env).returns('production') + expect(subject).to_not be_nil + end + end + end + describe 'auth_config_checks' do - shared_examples_for 'problem detection for login providers' do + shared_examples 'problem detection for login providers' do context 'when disabled' do it 'returns nil' do SiteSetting.stubs(enable_setting).returns(false) @@ -167,7 +190,7 @@ describe AdminDashboardData do let(:enable_setting) { :enable_facebook_logins } let(:key) { :facebook_app_id } let(:secret) { :facebook_app_secret } - it_should_behave_like 'problem detection for login providers' + include_examples 'problem detection for login providers' end describe 'twitter' do @@ -175,7 +198,7 @@ describe AdminDashboardData do let(:enable_setting) { :enable_twitter_logins } let(:key) { :twitter_consumer_key } let(:secret) { :twitter_consumer_secret } - it_should_behave_like 'problem detection for login providers' + include_examples 'problem detection for login providers' end describe 'github' do @@ -183,7 +206,7 @@ describe AdminDashboardData do let(:enable_setting) { :enable_github_logins } let(:key) { :github_client_id } let(:secret) { :github_client_secret } - it_should_behave_like 'problem detection for login providers' + include_examples 'problem detection for login providers' end end