Add warning on admin dashboard if production env is configured to send email through gmail
This commit is contained in:
parent
acb2623b4b
commit
6abd9ddd2d
|
@ -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
|
|
@ -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: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
|
||||
clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. <a href="https://github.com/tomykaira/clockwork">Learn about clockwork here</a>.'
|
||||
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. <a href="https://github.com/mperham/sidekiq">Learn about Sidekiq here</a>.'
|
||||
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: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126" target="_blank">Tuning Ruby and Rails for Discourse</a>.'
|
||||
clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. <a href="https://github.com/tomykaira/clockwork" target="_blank">Learn about clockwork here</a>.'
|
||||
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. <a href="https://github.com/mperham/sidekiq" target="_blank">Learn about Sidekiq here</a>.'
|
||||
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 <a href="/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide#enable-facebook-logins" target="_blank">See this guide to learn more</a>.'
|
||||
|
@ -387,6 +387,7 @@ en:
|
|||
contact_email_missing: "You haven't provided a contact email for your site. Please update contact_email in the <a href='/admin/site_settings'>Site Settings</a>."
|
||||
contact_email_invalid: "The site contact email is invalid. Please update contact_email in the <a href='/admin/site_settings'>Site Settings</a>."
|
||||
title_nag: "The title Site Setting is still set to the default value. Please update it with your site's title in the <a href='/admin/site_settings'>Site Settings</a>."
|
||||
gmail_for_email_warning: "Your site is configured to use Gmail to send email. <a href='http://support.google.com/a/bin/answer.py?hl=en&answer=166852' target='_blank'>Gmail limits how many emails you can send</a>. Consider using an email service provider to ensure email deliverability."
|
||||
|
||||
content_types:
|
||||
education_new_reply:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue