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,38 @@
require "rails_helper"
RSpec.describe Recordings::Delete 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: "youtube", status: "ended")
end
let!(:recording) do
Recording.create!(
stream_session: session,
team: team,
status: "ready",
privacy_status: "public",
expires_at: 10.days.from_now,
storage_key: "teams/#{team.id}/sessions/#{session.id}/replay.mp4",
youtube_video_id: "abc123xyz"
)
end
it "elimina storage e revoca youtube_video_id" do
storage = instance_double(Recordings::Storage, delete: true)
allow(Recordings::Storage).to receive(:new).and_return(storage)
yt = instance_double(Youtube::VideoLifecycleService, delete!: true)
allow(Youtube::VideoLifecycleService).to receive(:new).with(recording).and_return(yt)
described_class.new(recording).call
expect(yt).to have_received(:delete!)
expect(storage).to have_received(:delete).at_least(:once)
recording.reload
expect(recording.deleted_at).to be_present
expect(recording.youtube_video_id).to be_nil
expect(recording.storage_key).to be_nil
end
end