From 91238af6f182fda8f9ca5a5357c0a16ed43a4c6e Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 Jul 2013 12:25:38 +1000 Subject: [PATCH] correct failing specs --- app/controllers/admin/dashboard_controller.rb | 14 ++++---------- .../controllers/admin/dashboard_controller_spec.rb | 8 +++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 03ba0ac44e4..986f15b66a3 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -1,19 +1,13 @@ class Admin::DashboardController < Admin::AdminController def index - # see https://github.com/rails/rails/issues/8167 - # TODO: after upgrading to Rails 4, try to remove "if cache_classes" - if Discourse::Application.config.cache_classes - dashboard_data = Rails.cache.fetch("admin-dashboard-data-#{Discourse::VERSION::STRING}", expires_in: 1.hour) do - AdminDashboardData.fetch_all.as_json - end - render json: dashboard_data - else - render_json_dump AdminDashboardData.fetch_all + dashboard_data = Rails.cache.fetch("admin-dashboard-data-#{Discourse::VERSION::STRING}", expires_in: 1.hour) do + AdminDashboardData.fetch_all.as_json end + render json: dashboard_data end def problems render_json_dump({problems: AdminDashboardData.fetch_problems}) end -end \ No newline at end of file +end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index a54bd6ea501..f46054d4d40 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -1,6 +1,12 @@ require 'spec_helper' +require_dependency 'discourse_version_check' describe Admin::DashboardController do + before do + #NOTE: Rails.cache should be blanked between tests, at the moment we can share state with it + # that is seriously bust on quite a few levels + Rails.cache.delete("admin-dashboard-data-#{Discourse::VERSION::STRING}") + end it "is a subclass of AdminController" do (Admin::DashboardController < Admin::AdminController).should be_true @@ -81,4 +87,4 @@ describe Admin::DashboardController do end end end -end \ No newline at end of file +end