From 65790452d833fc38460b2a5222c59896f9872af4 Mon Sep 17 00:00:00 2001 From: Kane York Date: Tue, 1 Sep 2015 13:32:35 -0700 Subject: [PATCH] Clean up the test checks when done --- app/models/admin_dashboard_data.rb | 31 +++++++++++++----------- spec/models/admin_dashboard_data_spec.rb | 4 +++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb index 001d23f3cc1..42535237636 100644 --- a/app/models/admin_dashboard_data.rb +++ b/app/models/admin_dashboard_data.rb @@ -33,9 +33,6 @@ class AdminDashboardData MOBILE_REPORTS ||= ['mobile_visits'] + ApplicationRequest.req_types.keys.select {|r| r =~ /mobile/}.map { |r| r + "_reqs" } def self.add_problem_check(*syms, &blk) - @problem_syms ||= [] - @problem_blocks ||= [] - @problem_syms.push(*syms) if syms @problem_blocks << blk if blk end @@ -52,19 +49,25 @@ class AdminDashboardData problems.compact end - add_problem_check :rails_env_check, :ruby_version_check, :host_names_check, - :gc_checks, :ram_check, :google_oauth2_config_check, - :facebook_config_check, :twitter_config_check, - :github_config_check, :s3_config_check, :image_magick_check, - :failing_emails_check, :default_logo_check, :contact_email_check, - :send_consumer_email_check, :title_check, - :site_description_check, :site_contact_username_check, - :notification_email_check + # used for testing + def self.reset_problem_checks + @problem_syms = [] + @problem_blocks = [] - add_problem_check do - sidekiq_check || queue_size_check + add_problem_check :rails_env_check, :ruby_version_check, :host_names_check, + :gc_checks, :ram_check, :google_oauth2_config_check, + :facebook_config_check, :twitter_config_check, + :github_config_check, :s3_config_check, :image_magick_check, + :failing_emails_check, :default_logo_check, :contact_email_check, + :send_consumer_email_check, :title_check, + :site_description_check, :site_contact_username_check, + :notification_email_check + + add_problem_check do + sidekiq_check || queue_size_check + end end - + reset_problem_checks def self.fetch_stats AdminDashboardData.new.as_json diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb index 80286f86046..36a029b4778 100644 --- a/spec/models/admin_dashboard_data_spec.rb +++ b/spec/models/admin_dashboard_data_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' describe AdminDashboardData do describe "adding new checks" do + after do + AdminDashboardData.reset_problem_checks + end + it 'calls the passed block' do called = false AdminDashboardData.add_problem_check do