Add a warning on dashboard if enforce_global_nicknames is checked, but access key is blank.

This commit is contained in:
Neil Lalonde 2013-11-18 13:44:55 -05:00
parent 281f839e54
commit ae58a7db95
4 changed files with 41 additions and 10 deletions

View File

@ -564,6 +564,9 @@ table.api-keys {
.actions { .actions {
text-align: right; text-align: right;
} }
.btn {
background-color: #ccc;
}
} }
} }

View File

@ -41,6 +41,7 @@ class AdminDashboardData
access_password_removal, access_password_removal,
site_contact_username_check, site_contact_username_check,
notification_email_check, notification_email_check,
enforce_global_nicknames_check
].compact ].compact
end end
@ -167,6 +168,10 @@ class AdminDashboardData
I18n.t('dashboard.ruby_version_warning') if RUBY_VERSION == '2.0.0' and RUBY_PATCHLEVEL < 247 I18n.t('dashboard.ruby_version_warning') if RUBY_VERSION == '2.0.0' and RUBY_PATCHLEVEL < 247
end end
def enforce_global_nicknames_check
I18n.t('dashboard.enforce_global_nicknames_warning') if SiteSetting.enforce_global_nicknames and !SiteSetting.discourse_org_access_key.present?
end
# TODO: generalize this method of putting i18n keys with expiry in redis # TODO: generalize this method of putting i18n keys with expiry in redis
# that should be reported on the admin dashboard: # that should be reported on the admin dashboard:
def access_password_removal def access_password_removal

View File

@ -440,6 +440,7 @@ en:
access_password_removal: "Your site was using the access_password setting, which has been removed. The login_required and must_approve_users settings have been enabled, which should be used instead. You can change them in the <a href='/admin/site_settings'>Site Settings</a>. Be sure to <a href='/admin/users/list/pending'>approve users in the Pending Users list</a>. (This message will go away after 2 days.)" access_password_removal: "Your site was using the access_password setting, which has been removed. The login_required and must_approve_users settings have been enabled, which should be used instead. You can change them in the <a href='/admin/site_settings'>Site Settings</a>. Be sure to <a href='/admin/users/list/pending'>approve users in the Pending Users list</a>. (This message will go away after 2 days.)"
site_contact_username_warning: "The site_contact_username setting is blank. Please update it in the <a href='/admin/site_settings'>Site Settings</a>. Set it to the username of an admin user who should be the sender of system messages." site_contact_username_warning: "The site_contact_username setting is blank. Please update it in the <a href='/admin/site_settings'>Site Settings</a>. Set it to the username of an admin user who should be the sender of system messages."
notification_email_warning: "The notification_email setting is blank. Please update it in the <a href='/admin/site_settings'>Site Settings</a>." notification_email_warning: "The notification_email setting is blank. Please update it in the <a href='/admin/site_settings'>Site Settings</a>."
enforce_global_nicknames_warning: "The enforce_global_nicknames setting is checked, but the discourse_org_access_key is blank. A Discourse.org access key is required to use the enforce_global_nicknames setting. Please update your <a href='/admin/site_settings'>Site Settings</a>."
content_types: content_types:
education_new_reply: education_new_reply:

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe AdminDashboardData do describe AdminDashboardData do
describe "rails_env_check" do describe "rails_env_check" do
subject { AdminDashboardData.new.rails_env_check } subject { described_class.new.rails_env_check }
it 'returns nil when running in production mode' do it 'returns nil when running in production mode' do
Rails.stubs(:env).returns('production') Rails.stubs(:env).returns('production')
@ -22,7 +22,7 @@ describe AdminDashboardData do
end end
describe 'host_names_check' do describe 'host_names_check' do
subject { AdminDashboardData.new.host_names_check } subject { described_class.new.host_names_check }
it 'returns nil when host_names is set' do it 'returns nil when host_names is set' do
Discourse.stubs(:current_hostname).returns('something.com') Discourse.stubs(:current_hostname).returns('something.com')
@ -41,7 +41,7 @@ describe AdminDashboardData do
end end
describe 'gc_checks' do describe 'gc_checks' do
subject { AdminDashboardData.new.gc_checks } subject { described_class.new.gc_checks }
it 'returns nil when gc params are set' do it 'returns nil when gc params are set' do
ENV.stubs(:[]).with('RUBY_GC_MALLOC_LIMIT').returns(90000000) ENV.stubs(:[]).with('RUBY_GC_MALLOC_LIMIT').returns(90000000)
@ -55,7 +55,7 @@ describe AdminDashboardData do
end end
describe 'sidekiq_check' do describe 'sidekiq_check' do
subject { AdminDashboardData.new.sidekiq_check } subject { described_class.new.sidekiq_check }
it 'returns nil when sidekiq processed a job recently' do it 'returns nil when sidekiq processed a job recently' do
Jobs.stubs(:last_job_performed_at).returns(1.minute.ago) Jobs.stubs(:last_job_performed_at).returns(1.minute.ago)
@ -89,7 +89,7 @@ describe AdminDashboardData do
end end
describe 'ram_check' do describe 'ram_check' do
subject { AdminDashboardData.new.ram_check } subject { described_class.new.ram_check }
it 'returns nil when total ram is 1 GB' do it 'returns nil when total ram is 1 GB' do
MemInfo.any_instance.stubs(:mem_total).returns(1025272) MemInfo.any_instance.stubs(:mem_total).returns(1025272)
@ -108,7 +108,7 @@ describe AdminDashboardData do
end end
describe 'send_consumer_email_check' do describe 'send_consumer_email_check' do
subject { AdminDashboardData.new.send_consumer_email_check } subject { described_class.new.send_consumer_email_check }
it 'returns nil if gmail.com is not in the smtp_settings address' do it 'returns nil if gmail.com is not in the smtp_settings address' do
ActionMailer::Base.stubs(:smtp_settings).returns({address: 'mandrillapp.com'}) ActionMailer::Base.stubs(:smtp_settings).returns({address: 'mandrillapp.com'})
@ -131,7 +131,7 @@ describe AdminDashboardData do
end end
describe 'default_logo_check' do describe 'default_logo_check' do
subject { AdminDashboardData.new.default_logo_check } subject { described_class.new.default_logo_check }
describe 'favicon_url check' do describe 'favicon_url check' do
before do before do
@ -220,7 +220,7 @@ describe AdminDashboardData do
end end
describe 'facebook' do describe 'facebook' do
subject { AdminDashboardData.new.facebook_config_check } subject { described_class.new.facebook_config_check }
let(:enable_setting) { :enable_facebook_logins } let(:enable_setting) { :enable_facebook_logins }
let(:key) { :facebook_app_id } let(:key) { :facebook_app_id }
let(:secret) { :facebook_app_secret } let(:secret) { :facebook_app_secret }
@ -228,7 +228,7 @@ describe AdminDashboardData do
end end
describe 'twitter' do describe 'twitter' do
subject { AdminDashboardData.new.twitter_config_check } subject { described_class.new.twitter_config_check }
let(:enable_setting) { :enable_twitter_logins } let(:enable_setting) { :enable_twitter_logins }
let(:key) { :twitter_consumer_key } let(:key) { :twitter_consumer_key }
let(:secret) { :twitter_consumer_secret } let(:secret) { :twitter_consumer_secret }
@ -236,7 +236,7 @@ describe AdminDashboardData do
end end
describe 'github' do describe 'github' do
subject { AdminDashboardData.new.github_config_check } subject { described_class.new.github_config_check }
let(:enable_setting) { :enable_github_logins } let(:enable_setting) { :enable_github_logins }
let(:key) { :github_client_id } let(:key) { :github_client_id }
let(:secret) { :github_client_secret } let(:secret) { :github_client_secret }
@ -244,4 +244,26 @@ describe AdminDashboardData do
end end
end end
describe "enforce_global_nicknames_check" do
subject { described_class.new.enforce_global_nicknames_check }
it 'returns nil when enforce_global_nicknames and discourse_org_access_key are set' do
SiteSetting.stubs(:enforce_global_nicknames).returns(true)
SiteSetting.stubs(:discourse_org_access_key).returns('123')
subject.should be_nil
end
it 'returns a string when enforce_global_nicknames is true but discourse_org_access_key is not' do
SiteSetting.stubs(:enforce_global_nicknames).returns(true)
SiteSetting.stubs(:discourse_org_access_key).returns('')
subject.should_not be_nil
end
it 'returns nil when enforce_global_nicknames is false and discourse_org_access_key is set' do
SiteSetting.stubs(:enforce_global_nicknames).returns(false)
SiteSetting.stubs(:discourse_org_access_key).returns('123')
subject.should be_nil
end
end
end end