2021-12-20 07:59:11 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe Jobs::ProblemChecks do
|
2024-02-23 11:20:32 +08:00
|
|
|
before do
|
|
|
|
::ProblemCheck::ScheduledCheck =
|
|
|
|
Class.new(ProblemCheck) do
|
|
|
|
self.perform_every = 30.minutes
|
|
|
|
|
|
|
|
def call = []
|
|
|
|
end
|
|
|
|
|
|
|
|
::ProblemCheck::NonScheduledCheck = Class.new(ProblemCheck) { def call = [] }
|
|
|
|
end
|
2023-11-03 09:05:29 +08:00
|
|
|
|
2021-12-20 07:59:11 +08:00
|
|
|
after do
|
|
|
|
Discourse.redis.flushdb
|
|
|
|
AdminDashboardData.reset_problem_checks
|
|
|
|
|
2024-02-23 11:20:32 +08:00
|
|
|
ProblemCheck.send(:remove_const, "ScheduledCheck")
|
|
|
|
ProblemCheck.send(:remove_const, "NonScheduledCheck")
|
2023-11-06 08:57:02 +08:00
|
|
|
end
|
|
|
|
|
2024-02-23 11:20:32 +08:00
|
|
|
it "schedules the individual scheduled checks" do
|
|
|
|
expect_enqueued_with(job: :problem_check, args: { check_identifier: "scheduled_check" }) do
|
|
|
|
described_class.new.execute([])
|
2021-12-20 07:59:11 +08:00
|
|
|
end
|
2024-02-23 11:20:32 +08:00
|
|
|
end
|
2021-12-20 07:59:11 +08:00
|
|
|
|
2024-02-23 11:20:32 +08:00
|
|
|
it "does not schedule non-scheduled checks" do
|
|
|
|
expect_not_enqueued_with(
|
|
|
|
job: :problem_check,
|
|
|
|
args: {
|
|
|
|
check_identifier: "non_scheduled_check",
|
|
|
|
},
|
|
|
|
) { described_class.new.execute([]) }
|
2021-12-20 07:59:11 +08:00
|
|
|
end
|
2024-02-26 12:08:12 +08:00
|
|
|
|
|
|
|
it "does not schedule non-scheduled checks" do
|
|
|
|
expect_not_enqueued_with(
|
|
|
|
job: :problem_check,
|
|
|
|
args: {
|
|
|
|
check_identifier: "non_scheduled_check",
|
|
|
|
},
|
|
|
|
) { described_class.new.execute([]) }
|
|
|
|
end
|
2021-12-20 07:59:11 +08:00
|
|
|
end
|