Dashboard warning when host_names is localhost
This commit is contained in:
parent
c3c25b894a
commit
c8508d3f26
|
@ -10,7 +10,7 @@ class AdminDashboardData
|
||||||
@json ||= {
|
@json ||= {
|
||||||
reports: REPORTS.map { |type| Report.find(type) },
|
reports: REPORTS.map { |type| Report.find(type) },
|
||||||
total_users: User.count,
|
total_users: User.count,
|
||||||
problems: [rails_env_check].compact
|
problems: [rails_env_check, host_names_check].compact
|
||||||
}.merge(
|
}.merge(
|
||||||
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
|
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
|
||||||
)
|
)
|
||||||
|
@ -19,4 +19,8 @@ class AdminDashboardData
|
||||||
def rails_env_check
|
def rails_env_check
|
||||||
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env == 'production'
|
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env == 'production'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def host_names_check
|
||||||
|
I18n.t("dashboard.host_names_warning") if ['localhost', 'production.localhost'].include?(Discourse.current_hostname)
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -285,6 +285,7 @@ en:
|
||||||
|
|
||||||
dashboard:
|
dashboard:
|
||||||
rails_env_warning: "Your server is running in %{env} mode."
|
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."
|
||||||
|
|
||||||
site_settings:
|
site_settings:
|
||||||
default_locale: "The default language of this Discourse instance (ISO 639-1 Code)"
|
default_locale: "The default language of this Discourse instance (ISO 639-1 Code)"
|
||||||
|
|
|
@ -21,4 +21,23 @@ describe AdminDashboardData do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'host_names_check' do
|
||||||
|
subject { AdminDashboardData.new.host_names_check }
|
||||||
|
|
||||||
|
it 'returns nil when host_names is set' do
|
||||||
|
Discourse.stubs(:current_hostname).returns('something.com')
|
||||||
|
subject.should be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a string when host_name is localhost' do
|
||||||
|
Discourse.stubs(:current_hostname).returns('localhost')
|
||||||
|
subject.should_not be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a string when host_name is production.localhost' do
|
||||||
|
Discourse.stubs(:current_hostname).returns('production.localhost')
|
||||||
|
subject.should_not be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue