Files
MatchLiveTv/backend/spec/services/youtube/broadcast_service_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

31 lines
1.0 KiB
Ruby

require "rails_helper"
RSpec.describe Youtube::BroadcastService do
describe "#normalize_scheduled_start_time" do
subject(:service) { described_class.allocate }
it "usa tra ~20 secondi se scheduled_at è assente" do
travel_to Time.zone.parse("2026-06-03 20:00:00 UTC") do
t = service.send(:normalize_scheduled_start_time, nil)
expect(t).to eq(Time.utc(2026, 6, 3, 20, 0, 20))
end
end
it "sposta nel futuro se scheduled_at è nel passato" do
travel_to Time.zone.parse("2026-06-03 20:00:00 UTC") do
past = Time.zone.parse("2026-06-03 10:00:00")
t = service.send(:normalize_scheduled_start_time, past)
expect(t).to eq(Time.utc(2026, 6, 3, 20, 0, 20))
end
end
it "mantiene scheduled_at se è nel futuro entro 7 giorni" do
travel_to Time.zone.parse("2026-06-03 20:00:00 UTC") do
future = Time.zone.parse("2026-06-05 18:00:00")
t = service.send(:normalize_scheduled_start_time, future)
expect(t).to eq(future.utc)
end
end
end
end