Files
MatchLiveTv/backend/spec/requests/ops/health_spec.rb
Emiliano Frascaro 52cfffb83f Aggiunge monitoraggio ops: health check, log scanner, dashboard e notifiche.
Introduce incidenti con dedup, job Sidekiq ogni 3 min, scan log cron, /up/deep,
dashboard /admin/ops e push ntfy; include Sentry opzionale e fix test suite.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 08:16:47 +02:00

33 lines
1.0 KiB
Ruby

require "rails_helper"
RSpec.describe "Ops deep health", type: :request do
describe "GET /up/deep" do
it "restituisce summary JSON" do
allow_any_instance_of(Ops::HealthChecks).to receive(:summary).and_return(
status: "ok",
checked_at: Time.current.iso8601,
checks: []
)
get "/up/deep"
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)["status"]).to eq("ok")
end
it "richiede token quando OPS_HEALTH_TOKEN è impostato" do
allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with("OPS_HEALTH_TOKEN").and_return("secret-token")
allow_any_instance_of(Ops::HealthChecks).to receive(:summary).and_return(
status: "ok", checked_at: Time.current.iso8601, checks: []
)
get "/up/deep"
expect(response).to have_http_status(:unauthorized)
get "/up/deep", headers: { "X-Ops-Token" => "secret-token" }
expect(response).to have_http_status(:ok)
end
end
end