From 3959f36d1913e1baa163dc86f6d0776d02b37ca2 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 27 Aug 2024 10:59:56 -0400 Subject: [PATCH] Add checks about response body content to admin/dash spec (#30716) --- .../admin/dashboard_controller_spec.rb | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 25300fdd90..3e29ce1278 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -6,19 +6,30 @@ describe Admin::DashboardController do render_views describe 'GET #index' do + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Owner')) } + before do - allow(Admin::SystemCheck).to receive(:perform).and_return([ - Admin::SystemCheck::Message.new(:database_schema_check), - Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), - Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), - ]) - sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) + stub_system_checks + Fabricate :software_update + sign_in(user) end - it 'returns 200' do + it 'returns http success and body with system check messages' do get :index - expect(response).to have_http_status(200) + expect(response) + .to have_http_status(200) + .and have_attributes( + body: include(I18n.t('admin.system_checks.software_version_patch_check.message_html')) + ) + end + + private + + def stub_system_checks + stub_const 'Admin::SystemCheck::ACTIVE_CHECKS', [ + Admin::SystemCheck::SoftwareVersionCheck, + ] end end end