Una gara con punteggio non resta più «In programma» solo perché l'orario è futuro, e i replay usano le squadre del match invece della squadra di trasmissione. Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
2.5 KiB
Ruby
76 lines
2.5 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Recording do
|
|
let!(:club) { Club.create!(name: "Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
|
|
let!(:team) { club.teams.create!(name: "Team", sport: "volleyball") }
|
|
let!(:user) { User.create!(email: "coach@test.com", name: "Coach", password: "Password123", role: "coach") }
|
|
let!(:match) { team.matches.create!(opponent_name: "Rival", scheduled_at: 1.day.from_now) }
|
|
let!(:session) do
|
|
StreamSession.create!(
|
|
match: match,
|
|
user: user,
|
|
platform: "matchlivetv",
|
|
status: "ended",
|
|
privacy_status: "public"
|
|
)
|
|
end
|
|
|
|
it "is ready when status ready and not expired" do
|
|
rec = described_class.create!(
|
|
stream_session: session,
|
|
team: team,
|
|
status: "ready",
|
|
expires_at: 1.day.from_now,
|
|
storage_key: "teams/#{team.id}/sessions/#{session.id}/replay.mp4"
|
|
)
|
|
expect(rec).to be_ready
|
|
expect(rec.replay_url).to include("/replay/#{session.id}")
|
|
end
|
|
|
|
it "exposes default title from match" do
|
|
rec = described_class.create!(stream_session: session, team: team, status: "processing")
|
|
expect(rec.title_or_default).to eq("Team vs Rival")
|
|
end
|
|
|
|
it "usa le squadre del tabellone al posto della squadra di trasmissione" do
|
|
load Rails.root.join("db/seeds/plans.rb")
|
|
Billing::AssignPlan.call(club: club, plan_slug: "premium_full")
|
|
ClubMembership.create!(user: user, club: club, role: "owner")
|
|
tournament = Tournaments::Create.call(
|
|
club: club,
|
|
attrs: {
|
|
name: "Memorial",
|
|
sport_key: "pallavolo",
|
|
starts_on: Date.current,
|
|
ends_on: Date.current,
|
|
format_kind: "free"
|
|
}
|
|
)
|
|
home = tournament.participants.create!(name: "Gamma")
|
|
away = tournament.participants.create!(name: "Beta")
|
|
tournament_match = Tournaments::ScheduleMatch.call(
|
|
tournament: tournament,
|
|
attrs: {
|
|
home_participant_id: home.id,
|
|
away_participant_id: away.id,
|
|
scheduled_at: 1.hour.from_now
|
|
}
|
|
)
|
|
tournament_session = StreamSession.create!(
|
|
match: tournament_match,
|
|
user: user,
|
|
platform: "matchlivetv",
|
|
status: "ended",
|
|
privacy_status: "public"
|
|
)
|
|
rec = described_class.create!(
|
|
stream_session: tournament_session,
|
|
team: tournament.broadcast_team,
|
|
status: "ready",
|
|
title: "#{tournament.broadcast_team.name} vs Beta"
|
|
)
|
|
expect(rec.title_or_default).to eq("Gamma vs Beta")
|
|
expect(rec.default_title).to eq("Gamma vs Beta")
|
|
end
|
|
end
|