forked from discourse/discourse
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start detecting install problems and report them on the admin dashboa…
…rd. This commit adds check for Rails.env
- Loading branch information
Showing
9 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/assets/javascripts/admin/templates/dashboard.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class AdminDashboardData | ||
|
||
REPORTS = ['visits', 'signups', 'topics', 'posts', 'flags', 'users_by_trust_level', 'likes', 'emails'] | ||
|
||
def self.fetch | ||
AdminDashboardData.new | ||
end | ||
|
||
def as_json | ||
@json ||= { | ||
reports: REPORTS.map { |type| Report.find(type) }, | ||
total_users: User.count, | ||
problems: [rails_env_check].compact | ||
}.merge( | ||
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {} | ||
) | ||
end | ||
|
||
def rails_env_check | ||
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env == 'production' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
describe AdminDashboardData do | ||
|
||
describe "rails_env_check" do | ||
subject { AdminDashboardData.new.rails_env_check } | ||
|
||
it 'returns nil when running in production mode' do | ||
Rails.stubs(:env).returns('production') | ||
subject.should be_nil | ||
end | ||
|
||
it 'returns a string when running in development mode' do | ||
Rails.stubs(:env).returns('development') | ||
subject.should_not be_nil | ||
end | ||
|
||
it 'returns a string when running in test mode' do | ||
Rails.stubs(:env).returns('test') | ||
subject.should_not be_nil | ||
end | ||
end | ||
|
||
end |