Files
MatchLiveTv/backend/spec/services/webhooks/mediamtx_handler_spec.rb
T
eminuxandCursor 1e4e0560f1 Allinea le spec alla policy password e prepara i piani di test.
Senza questo la suite locale fallisce sulla complessità password e sui piani mancanti.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 23:20:31 +02:00

30 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe Webhooks::MediamtxHandler do
let(:user) { User.create!(email: "c@test.com", name: "C", password: "Password123", role: "coach") }
let(:club) { Club.create!(name: "MTX Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
let(:team) { club.teams.create!(name: "T", sport: "volleyball") }
let!(:match) { team.matches.create!(opponent_name: "Away") }
let!(:session) do
StreamSession.create!(
match: match, user: user, status: "live", platform: "youtube",
publish_token: "tok", started_at: Time.current
)
end
before do
allow_any_instance_of(Mediamtx::Client).to receive(:set_path_recording)
end
it "transitions to reconnecting on disconnect" do
described_class.new(event: "disconnect", session_id: session.id).call
expect(session.reload.status).to eq("reconnecting")
end
it "returns to live on reconnect" do
session.update!(status: "reconnecting")
described_class.new(event: "connect", session_id: session.id).call
expect(session.reload.status).to eq("live")
end
end