A platform for community discussion. Free, open, simple.
FEATURE: Add problem checks page to admin panel and allow ignoring problem checks (#39103)
Ted Johansson623f2279b0bc
diff --git a/app/controllers/admin/problem_checks_controller.rb b/app/controllers/admin/problem_checks_controller.rbnew file mode 100644index 00000000000..ec7e83e1919--- /dev/null+++ b/app/controllers/admin/problem_checks_controller.rb@@ -0,0 +1,24 @@+# frozen_string_literal: true++class Admin::ProblemChecksController < Admin::AdminController+ def index+ trackers = ProblemCheckTracker.all.order(:identifier, :target)+ render_serialized(trackers, ProblemCheckTrackerSerializer)+ end++ def ignore+ tracker = ProblemCheckTracker.find(params[:problem_check_id])++ tracker.ignore!++ head :no_content+ end++ def watch+ tracker = ProblemCheckTracker.find(params[:problem_check_id])++ tracker.watch!++ head :no_content+ end+enddiff --git a/app/jobs/scheduled/notify_admins_of_problems.rb b/app/jobs/scheduled/notify_admins_of_problems.rbindex 1b00f5f99a3..9d0c2d82533 100644--- a/app/jobs/scheduled/notify_admins_of_problems.rb+++ b/app/jobs/scheduled/notify_admins_of_problems.rb@@ -29,10 +29,10 @@ module Jobsprivatedef persistent_problems?- ProblemCheckTracker.where(- "last_problem_at > last_success_at AND last_success_at < ?",- 2.days.ago,- ).exists?+ ProblemCheckTracker+ .watched+ .where("last_problem_at > last_success_at AND last_success_at < ?", 2.days.ago)+ .exists?endendenddiff --git a/app/models/problem_check_tracker.rb b/app/models/problem_check_tracker.rbindex 984c4124d55..5671cf81fe7 100644--- a/app/models/problem_check_tracker.rb+++ b/app/models/problem_check_tracker.rb@@ -7,6 +7,8 @@ class ProblemCheckTracker < ActiveRecord::Basescope :failing, -> { where("last_problem_at = last_run_at") }scope :passing, -> { where("last_success_at = last_run_at") }+ scope :ignored, -> { where.not(ignored_at: nil) }+ scope :watched, -> { where(ignored_at: nil) }before_destroy :silence_the_alarm@@ -26,6 +28,28 @@ class ProblemCheckTracker < ActiveRecord::Baselast_success_at == last_run_atend+ def ignored?+ ignored_at.present?+ end++ def watched?+ !ignored?+ end++ def ignore!+ return if ignored?++ touch(:ignored_at)+ silence_the_alarm+ end++ def watch!+ return if watched?++ update!(ignored_at: nil)+ sound_the_alarm if sound_the_alarm?+ end+def problem!(next_run_at: nil, details: {})now = Time.current@@ -41,12 +65,6 @@ class ProblemCheckTracker < ActiveRecord::Basesilence_the_alarmend- def reset(next_run_at: nil)- now = Time.current-- update!(blips: 0, last_run_at: now, last_success_at: now, next_run_at:)- end-def checkcheck = ProblemCheck[identifier]@@ -60,12 +78,18 @@ class ProblemCheckTracker < ActiveRecord::Baseprivate+ def reset(next_run_at: nil)+ now = Time.current++ update!(blips: 0, last_run_at: now, last_success_at: now, next_run_at:)+ end+def update_notice_details(details)admin_notice.where(identifier:).update_all(details: details.merge(target:))enddef sound_the_alarm?- failing? && blips > check.max_blips+ watched? && failing? && blips > check.max_blipsenddef sound_the_alarm@@ -92,6 +116,7 @@ end# blips :integer default(0), not null# details :json# identifier :string not null+# ignored_at :datetime# last_problem_at :datetime# last_run_at :datetime# last_success_at :datetimediff --git a/app/serializers/problem_check_tracker_serializer.rb b/app/serializers/problem_check_tracker_serializer.rbnew file mode 100644index 00000000000..cc437229b11--- /dev/null+++ b/app/serializers/problem_check_tracker_serializer.rb@@ -0,0 +1,13 @@+# frozen_string_literal: true++class ProblemCheckTrackerSerializer < ApplicationSerializer+ attributes :id, :identifier, :target, :last_run_at, :ignored, :status++ def status+ object.passing? ? "passing" : "failing"+ end++ def ignored+ object.ignored?+ end+enddiff --git a/app/services/admin_notices/dismiss.rb b/app/services/admin_notices/dismiss.rbindex 77cd50be936..4259ef3a1c4 100644--- a/app/services/admin_notices/dismiss.rb+++ b/app/services/admin_notices/dismiss.rb@@ -15,7 +15,7 @@ class AdminNotices::Dismisstransaction dostep :destroy- step :reset_problem_check+ step :ignore_problem_checkendprivate@@ -34,10 +34,10 @@ class AdminNotices::Dismissadmin_notice.destroy!end- def reset_problem_check(admin_notice:)+ def ignore_problem_check(admin_notice:)return if admin_notice.blank?target = admin_notice.details&.dig("target") || ProblemCheck::NO_TARGET- ProblemCheckTracker.find_by(identifier: admin_notice.identifier, target:)&.reset+ ProblemCheckTracker.find_by(identifier: admin_notice.identifier, target:)&.ignore!endenddiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex eb30e9f2f24..72800658455 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -6532,6 +6532,20 @@ en:logs:title: "Logs"header_description: "View and manage logs for backups, restores, and uploads"+ problem_checks:+ title: "Problem checks"+ header_description: "View all registered problem checks and their current status."+ identifier: "Check"+ target: "Target"+ priority: "Priority"+ status: "Status"+ passing: "Passing"+ failing: "Failing"+ last_run_at: "Last run"+ ignore: "Ignore"+ watch: "Watch"+ more_options:+ title: "More options"reports:title: "Reports"header_description: "Reports are a powerful tool to help you understand what’s happening on your site. They can help you identify trends, spot problems, and make decisions based on data."@@ -6714,7 +6728,7 @@ en:installed_version: "Installed"latest_version: "Latest"problems_found: "Some advice based on your current site settings"- dismiss_notice: "Dismiss"+ dismiss_notice: "Ignore"new_features:title: "What's new?"subtitle: "We are releasing new features and improvements all the time. This page covers the highlights, but you can click 'Learn more' to see extensive release notes."diff --git a/config/routes.rb b/config/routes.rbindex 029b3ecb1fb..d8e4d26563c 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -436,6 +436,8 @@ Discourse::Application.routes.draw doget "login-and-authentication/#{location}" => "site_settings#index"end+ # Needed for back-end routing to work.+ #get "navigation" => "site_settings#index"get "notifications" => "site_settings#index"get "rate-limits" => "site_settings#index"@@ -505,6 +507,11 @@ Discourse::Application.routes.draw doget "section/:section_id" => "section#show", :constraints => AdminConstraint.newresources :admin_notices, only: %i[destroy], constraints: AdminConstraint.new+ resources :problem_checks, only: %i[index], constraints: AdminConstraint.new do+ put "ignore" => "problem_checks#ignore"+ put "watch" => "problem_checks#watch"+ end+ get "problem-checks" => "problem_checks#index"delete "unknown_reviewables/destroy" => "unknown_reviewables#destroy"end # admin namespacediff --git a/db/migrate/20260402023645_add_ignored_at_to_problem_check_trackers.rb b/db/migrate/20260402023645_add_ignored_at_to_problem_check_trackers.rbnew file mode 100644index 00000000000..6886bc37587--- /dev/null+++ b/db/migrate/20260402023645_add_ignored_at_to_problem_check_trackers.rb@@ -0,0 +1,6 @@+# frozen_string_literal: true+class AddIgnoredAtToProblemCheckTrackers < ActiveRecord::Migration[8.0]+ def change+ add_column :problem_check_trackers, :ignored_at, :datetime+ end+enddiff --git a/frontend/discourse/admin/components/admin-config-areas/problem-checks-list.gjs b/frontend/discourse/admin/components/admin-config-areas/problem-checks-list.gjsnew file mode 100644index 00000000000..3957860959a--- /dev/null+++ b/frontend/discourse/admin/components/admin-config-areas/problem-checks-list.gjs@@ -0,0 +1,31 @@+import ProblemCheckItem from "discourse/admin/components/problem-check-item";+import { i18n } from "discourse-i18n";++const ProblemChecksList = <template>+ <table class="d-table admin-problem-checks__items">+ <thead class="d-table__header">+ <tr class="d-table__row">+ <th class="d-table__header-cell">{{i18n+ "admin.config.problem_checks.status"+ }}</th>+ <th class="d-table__header-cell">{{i18n+ "admin.config.problem_checks.identifier"+ }}</th>+ <th class="d-table__header-cell">{{i18n+ "admin.config.problem_checks.target"+ }}</th>+ <th class="d-table__header-cell">{{i18n+ "admin.config.problem_checks.last_run_at"+ }}</th>+ <th class="d-table__header-cell"></th>+ </tr>+ </thead>+ <tbody class="d-table__body">+ {{#each @problemChecks as |tracker|}}+ <ProblemCheckItem @tracker={{tracker}} />+ {{/each}}+ </tbody>+ </table>+</template>;++export default ProblemChecksList;diff --git a/frontend/discourse/admin/components/admin-notice.gjs b/frontend/discourse/admin/components/admin-notice.gjsindex 7a9bf4a5cd0..d20d345349b 100644--- a/frontend/discourse/admin/components/admin-notice.gjs+++ b/frontend/discourse/admin/components/admin-notice.gjs@@ -26,6 +26,7 @@ export default class AdminNotice extends Component {{{#if this.canDismiss}}<DButton@action={{this.dismiss}}+ @icon="eye-slash"@label="admin.dashboard.dismiss_notice"class="btn-default"/>diff --git a/frontend/discourse/admin/components/dashboard-problems.gjs b/frontend/discourse/admin/components/dashboard-problems.gjsindex ffbf3a5d9c6..ff9ed502992 100644--- a/frontend/discourse/admin/components/dashboard-problems.gjs+++ b/frontend/discourse/admin/components/dashboard-problems.gjs@@ -71,8 +71,6 @@ export default class DashboardProblems extends Component {@label="admin.dashboard.refresh_problems"class="btn-default"/>- {{i18n "admin.dashboard.last_checked"}}:- {{@problemsTimestamp}}</p></ConditionalLoadingSection></div>diff --git a/frontend/discourse/admin/components/problem-check-item.gjs b/frontend/discourse/admin/components/problem-check-item.gjsnew file mode 100644index 00000000000..5953c5da63e--- /dev/null+++ b/frontend/discourse/admin/components/problem-check-item.gjs@@ -0,0 +1,102 @@+import Component from "@glimmer/component";+import { fn, get } from "@ember/helper";+import { action } from "@ember/object";+import { service } from "@ember/service";+import DButton from "discourse/components/d-button";+import formatDate from "discourse/helpers/format-date";+import { ajax } from "discourse/lib/ajax";+import { popupAjaxError } from "discourse/lib/ajax-error";+import { notEq } from "discourse/truth-helpers";+import { i18n } from "discourse-i18n";++const STATUS_CLASSES = {+ passing: "--success",+ failing: "--critical",+};++const STATUS_LABELS = {+ passing: i18n("admin.config.problem_checks.passing"),+ failing: i18n("admin.config.problem_checks.failing"),+};++export default class ProblemCheckItem extends Component {+ @service router;++ @action+ async ignore(tracker) {+ try {+ await ajax(`/admin/problem_checks/${tracker.id}/ignore.json`, {+ type: "PUT",+ });+ this.router.refresh();+ } catch (error) {+ popupAjaxError(error);+ }+ }++ @action+ async watch(tracker) {+ try {+ await ajax(`/admin/problem_checks/${tracker.id}/watch.json`, {+ type: "PUT",+ });+ this.router.refresh();+ } catch (error) {+ popupAjaxError(error);+ }+ }++ <template>+ <tr class="d-table__row --{{@tracker.status}}">+ <td class="d-table__cell --overview">+ <div class="status-label {{get STATUS_CLASSES @tracker.status}}">+ <div class="status-label-indicator"></div>+ <div class="status-label-text">+ {{get STATUS_LABELS @tracker.status}}+ </div>+ </div>+ </td>+ <td class="d-table__cell --detail">+ <div class="d-table__mobile-label">{{i18n+ "admin.config.problem_checks.identifier"+ }}</div>+ {{@tracker.identifier}}+ </td>+ <td class="d-table__cell --detail">+ <div class="d-table__mobile-label">{{i18n+ "admin.config.problem_checks.target"+ }}</div>+ {{#if (notEq @tracker.target "__NULL__")}}+ {{@tracker.target}}+ {{/if}}+ </td>+ <td class="d-table__cell --detail">+ <div class="d-table__mobile-label">{{i18n+ "admin.config.problem_checks.last_run_at"+ }}</div>+ {{#if @tracker.last_run_at}}+ {{formatDate @tracker.last_run_at leaveAgo="true"}}+ {{/if}}+ </td>+ <td class="d-table__cell --controls">+ <div class="d-table__cell-actions">+ {{#if @tracker.ignored}}+ <DButton+ @action={{fn this.watch @tracker}}+ @label="admin.config.problem_checks.watch"+ @icon="eye"+ class="btn-default btn-small"+ />+ {{else}}+ <DButton+ @action={{fn this.ignore @tracker}}+ @label="admin.config.problem_checks.ignore"+ @icon="eye-slash"+ class="btn-default btn-small"+ />+ {{/if}}+ </div>+ </td>+ </tr>+ </template>+}diff --git a/frontend/discourse/admin/routes/admin-problem-checks/index.js b/frontend/discourse/admin/routes/admin-problem-checks/index.jsnew file mode 100644index 00000000000..a29804ff17f--- /dev/null+++ b/frontend/discourse/admin/routes/admin-problem-checks/index.js@@ -0,0 +1,13 @@+import { ajax } from "discourse/lib/ajax";+import DiscourseRoute from "discourse/routes/discourse";+import { i18n } from "discourse-i18n";++export default class AdminProblemChecksIndexRoute extends DiscourseRoute {+ titleToken() {+ return i18n("admin.config.problem_checks.title");+ }++ async model() {+ return await ajax("/admin/problem_checks.json");+ }+}diff --git a/frontend/discourse/admin/routes/admin-route-map.js b/frontend/discourse/admin/routes/admin-route-map.jsindex 5ebe5a93043..d96ad5ed6ca 100644--- a/frontend/discourse/admin/routes/admin-route-map.js+++ b/frontend/discourse/admin/routes/admin-route-map.js@@ -156,6 +156,14 @@ export default function () {});+ this.route(+ "adminProblemChecks",+ { path: "/problem-checks", resetNamespace: true },+ function () {+ this.route("index", { path: "/" });+ }+ );+this.route("adminReports",{ path: "/reports", resetNamespace: true },diff --git a/frontend/discourse/admin/templates/admin-problem-checks.gjs b/frontend/discourse/admin/templates/admin-problem-checks.gjsnew file mode 100644index 00000000000..0717aa7811a--- /dev/null+++ b/frontend/discourse/admin/templates/admin-problem-checks.gjs@@ -0,0 +1,26 @@+import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";+import DPageHeader from "discourse/components/d-page-header";+import { i18n } from "discourse-i18n";++export default <template>+ <div class="admin-problem-checks admin-config-page">+ <DPageHeader+ @titleLabel={{i18n "admin.config.problem_checks.title"}}+ @descriptionLabel={{i18n+ "admin.config.problem_checks.header_description"+ }}+ >+ <:breadcrumbs>+ <DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />+ <DBreadcrumbsItem+ @path="/admin/problem-checks"+ @label={{i18n "admin.config.problem_checks.title"}}+ />+ </:breadcrumbs>+ </DPageHeader>++ <div class="admin-container admin-config-page__main-area">+ {{outlet}}+ </div>+ </div>+</template>diff --git a/frontend/discourse/admin/templates/admin-problem-checks/index.gjs b/frontend/discourse/admin/templates/admin-problem-checks/index.gjsnew file mode 100644index 00000000000..5ab9dcbf3a0--- /dev/null+++ b/frontend/discourse/admin/templates/admin-problem-checks/index.gjs@@ -0,0 +1,5 @@+import ProblemChecksList from "discourse/admin/components/admin-config-areas/problem-checks-list";++export default <template>+ <ProblemChecksList @problemChecks={{@model}} />+</template>diff --git a/frontend/discourse/app/lib/sidebar/admin-nav-map.js b/frontend/discourse/app/lib/sidebar/admin-nav-map.jsindex 3c49d1df205..ce09e7c5f4f 100644--- a/frontend/discourse/app/lib/sidebar/admin-nav-map.js+++ b/frontend/discourse/app/lib/sidebar/admin-nav-map.js@@ -545,6 +545,13 @@ export const ADMIN_NAV_MAP = [icon: "code",settings_area: "embedding",},+ {+ name: "admin_problem_checks",+ route: "adminProblemChecks",+ label: "admin.config.problem_checks.title",+ description: "admin.config.problem_checks.header_description",+ icon: "heart",+ },{name: "admin_rate_limits",route: "adminConfig.rate-limits.settings",diff --git a/spec/fabricators/problem_check_tracker_fabricator.rb b/spec/fabricators/problem_check_tracker_fabricator.rbindex 77f4a819f38..24ee25bb4f3 100644--- a/spec/fabricators/problem_check_tracker_fabricator.rb+++ b/spec/fabricators/problem_check_tracker_fabricator.rb@@ -1,3 +1,3 @@# frozen_string_literal: true-Fabricator(:problem_check_tracker) {}+Fabricator(:problem_check_tracker) { identifier "twitter_login" }diff --git a/spec/jobs/scheduled/notify_admins_of_problems_spec.rb b/spec/jobs/scheduled/notify_admins_of_problems_spec.rbindex 6cc277f2e13..eb6afb6f6f5 100644--- a/spec/jobs/scheduled/notify_admins_of_problems_spec.rb+++ b/spec/jobs/scheduled/notify_admins_of_problems_spec.rb@@ -13,6 +13,17 @@ RSpec.describe ::Jobs::NotifyAdminsOfProblems doexpect { described_class.new.execute({}) }.to change { Notification.count }.by(1)end+ it "does not include ignored problem checks" do+ ProblemCheckTracker.create!(+ identifier: "bad_favicon_url",+ last_success_at: 3.days.ago,+ last_problem_at: 1.hour.ago,+ ignored_at: 1.day.ago,+ )++ expect { described_class.new.execute({}) }.not_to change { Notification.count }+ end+it "does not replace old notification created in last 7 days" doProblemCheckTracker.create!(identifier: "bad_favicon_url",diff --git a/spec/models/problem_check_tracker_spec.rb b/spec/models/problem_check_tracker_spec.rbindex 17a376acea5..ed5b75721d6 100644--- a/spec/models/problem_check_tracker_spec.rb+++ b/spec/models/problem_check_tracker_spec.rb@@ -121,12 +121,91 @@ RSpec.describe ProblemCheckTracker doendend+ describe "#ignored?" do+ let(:problem_tracker) { described_class.new(ignored_at:) }++ context "when the ignored timestamp is set" do+ let(:ignored_at) { 1.day.ago }++ it { expect(problem_tracker).to be_ignored }+ end++ context "when the ignored timestamp is not set" do+ let(:ignored_at) { nil }++ it { expect(problem_tracker).not_to be_ignored }+ end+ end++ describe "#watched?" do+ let(:problem_tracker) { described_class.new(ignored_at:) }++ context "when the ignored timestamp is set" do+ let(:ignored_at) { 1.day.ago }++ it { expect(problem_tracker).not_to be_watched }+ end++ context "when the ignored timestamp is not set" do+ let(:ignored_at) { nil }++ it { expect(problem_tracker).to be_watched }+ end+ end++ describe "#ignore!" do+ let(:problem_tracker) { Fabricate(:problem_check_tracker, ignored_at:) }++ context "when not currently ignored" do+ let(:ignored_at) { nil }++ it "sets the ignore timestamp" do+ freeze_time++ expect { problem_tracker.ignore! }.to change { problem_tracker.ignored_at }.from(nil).to(+ be_within_one_second_of Time.current+ )+ end+ end++ context "when already ignored" do+ let(:ignored_at) { 1.day.ago }++ it "does not touch the ignore timestamp" do+ expect { problem_tracker.ignore! }.not_to change { problem_tracker.ignored_at }+ end+ end+ end++ describe "#watch!" do+ let(:problem_tracker) { Fabricate(:problem_check_tracker, ignored_at:) }++ context "when not currently ignored" do+ let(:ignored_at) { nil }++ it "does not touch the ignore timestamp" do+ expect { problem_tracker.watch! }.not_to change { problem_tracker.ignored_at }+ end+ end++ context "when currently ignored" do+ let(:ignored_at) { 1.day.ago }++ it "clears the ignore timestamp" do+ expect { problem_tracker.watch! }.to change { problem_tracker.ignored_at }.from(+ be_within_one_second_of ignored_at+ ).to(nil)+ end+ end+ end+describe "#problem!" dolet(:problem_tracker) doFabricate(:problem_check_tracker,identifier: "twitter_login",target: "foo",+ ignored_at:,**original_attributes,)end@@ -143,6 +222,7 @@ RSpec.describe ProblemCheckTracker dolet(:blips) { 0 }let(:updated_attributes) { { blips: 1 } }+ let(:ignored_at) { nil }it dofreeze_time@@ -155,10 +235,24 @@ RSpec.describe ProblemCheckTracker docontext "when the maximum number of blips have been surpassed" dolet(:blips) { 1 }- it "sounds the alarm" do- expect { problem_tracker.problem!(next_run_at: 24.hours.from_now) }.to change {- AdminNotice.problem.count- }.by(1)+ context "when the check isn't being ignored" do+ let(:ignored_at) { nil }++ it "sounds the alarm" do+ expect { problem_tracker.problem!(next_run_at: 24.hours.from_now) }.to change {+ AdminNotice.problem.count+ }.by(1)+ end+ end++ context "when the check is being ignored" do+ let(:ignored_at) { 1.day.ago }++ it "does not sound the alarm" do+ expect { problem_tracker.problem!(next_run_at: 24.hours.from_now) }.not_to change {+ AdminNotice.problem.count+ }+ endendend@@ -283,30 +377,4 @@ RSpec.describe ProblemCheckTracker doendendend-- describe "#reset" do- let(:problem_tracker) do- Fabricate(:problem_check_tracker, identifier: "twitter_login", **original_attributes)- end-- let(:original_attributes) do- {- blips: 0,- last_problem_at: 1.week.ago,- last_success_at: Time.current,- last_run_at: 24.hours.ago,- next_run_at: nil,- }- end-- let(:updated_attributes) { { blips: 0 } }-- it do- freeze_time-- expect { problem_tracker.reset(next_run_at: 24.hours.from_now) }.to change {- problem_tracker.attributes- }.to(hash_including(updated_attributes))- end- endenddiff --git a/spec/requests/admin/problem_checks_controller_spec.rb b/spec/requests/admin/problem_checks_controller_spec.rbnew file mode 100644index 00000000000..882a664b28d--- /dev/null+++ b/spec/requests/admin/problem_checks_controller_spec.rb@@ -0,0 +1,99 @@+# frozen_string_literal: true++RSpec.describe Admin::ProblemChecksController do+ fab!(:admin)+ fab!(:user)+ fab!(:problem_check_tracker) do+ Fabricate(+ :problem_check_tracker,+ identifier: "rails_env",+ target: ProblemCheck::NO_TARGET,+ blips: 0,+ last_run_at: 1.hour.ago,+ last_success_at: 1.hour.ago,+ )+ end++ describe "#index" do+ context "when logged in as admin" do+ before { sign_in(admin) }++ it "returns problem check trackers" do+ get "/admin/problem_checks.json"++ expect(response.status).to eq(200)++ trackers = response.parsed_body++ expect(trackers.map { |t| t["identifier"] }).to contain_exactly("rails_env")+ end+ end++ context "when not logged in as admin" do+ before { sign_in(user) }++ it "returns a not found error" do+ get "/admin/problem_checks.json"+ expect(response.status).to eq(404)+ end+ end+ end++ describe "#ignore" do+ context "when tracker exists" do+ before { sign_in(admin) }++ it "ignores the problem" do+ put "/admin/problem_checks/#{problem_check_tracker.id}/ignore.json"+ expect(response.status).to eq(204)+ end+ end++ context "when tracker does not exist" do+ before { sign_in(admin) }++ it "returns a not found error" do+ put "/admin/problem_checks/1337/ignore.json"+ expect(response.status).to eq(404)+ end+ end++ context "when not logged in as admin" do+ before { sign_in(user) }++ it "returns a not found error" do+ put "/admin/problem_checks/#{problem_check_tracker.id}/ignore.json"+ expect(response.status).to eq(404)+ end+ end+ end++ describe "#watch" do+ context "when tracker exists" do+ before { sign_in(admin) }++ it "watches the problem" do+ put "/admin/problem_checks/#{problem_check_tracker.id}/watch.json"+ expect(response.status).to eq(204)+ end+ end++ context "when tracker does not exist" do+ before { sign_in(admin) }++ it "returns a not found error" do+ put "/admin/problem_checks/1337/watch.json"+ expect(response.status).to eq(404)+ end+ end++ context "when not logged in as admin" do+ before { sign_in(user) }++ it "returns a not found error" do+ put "/admin/problem_checks/#{problem_check_tracker.id}/watch.json"+ expect(response.status).to eq(404)+ end+ end+ end+enddiff --git a/spec/services/admin_notices/dismiss_spec.rb b/spec/services/admin_notices/dismiss_spec.rbindex b26a1ff53e0..bffd5032dc7 100644--- a/spec/services/admin_notices/dismiss_spec.rb+++ b/spec/services/admin_notices/dismiss_spec.rb@@ -41,12 +41,12 @@ RSpec.describe(AdminNotices::Dismiss) doexpect { result }.to change { AdminNotice.count }.from(1).to(0)end- it "resets any associated problem check" do- expect { result }.to change { problem_check.reload.blips }.from(3).to(0)+ it "ignores any associated problem check" do+ expect { result }.to change { problem_check.reload.ignored? }.from(false).to(true)endend- context "when the admin notice has a specific target" do+ context "when the associated problem check has a specific target" dofab!(:admin_notice) doFabricate(:admin_notice,@@ -67,8 +67,8 @@ RSpec.describe(AdminNotices::Dismiss) doit { is_expected.to run_successfully }- it "resets the problem check with the matching target" do- expect { result }.to change { problem_check.reload.blips }.from(5).to(0)+ it "ignores the problem check with the matching target" do+ expect { result }.to change { problem_check.reload.ignored? }.from(false).to(true)endendend