Completa modulo Replay: S3, retention, sync YouTube e gestione società.

Streaming chunked da Garage, purge con delete YouTube, privacy sincronizzata,
archivio club migliorato, retention 30/90 separata da stato abbonamento.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-08 09:33:59 +02:00
parent ae36d17adb
commit 74eee24293
17 changed files with 385 additions and 34 deletions

View File

@@ -0,0 +1,41 @@
require "rails_helper"
RSpec.describe Teams::Entitlements, "recordings" 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")
end
before { load Rails.root.join("db/seeds/plans.rb") }
it "premium attivo può creare registrazioni" do
Billing::AssignPlan.call(club: club, plan_slug: "premium_light")
ent = described_class.new(team)
expect(ent.can_create_recordings?).to be true
expect(ent.can_access_recordings?).to be true
end
it "abbonamento scaduto non crea ma accede all'archivio esistente" do
Billing::AssignPlan.call(club: club, plan_slug: "premium_light")
club.subscription.update!(status: "canceled")
Recording.create!(
stream_session: session,
team: team,
status: "ready",
privacy_status: "unlisted",
expires_at: 5.days.from_now,
storage_key: "k"
)
ent = described_class.new(team.reload)
expect(ent.can_create_recordings?).to be false
expect(ent.can_access_recordings?).to be true
end
it "premium full ha retention 90 giorni" do
Billing::AssignPlan.call(club: club, plan_slug: "premium_full")
expect(described_class.new(team).recording_retention_days).to eq(90)
end
end