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