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:
38
backend/spec/services/recordings/delete_spec.rb
Normal file
38
backend/spec/services/recordings/delete_spec.rb
Normal 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
|
||||
@@ -32,4 +32,16 @@ RSpec.describe Recordings::FinalizeSession do
|
||||
Billing::AssignPlan.call(club: club, plan_slug: "free")
|
||||
expect(described_class.new(session).call).to be_nil
|
||||
end
|
||||
|
||||
it "imposta retention 90 giorni con premium full" do
|
||||
Billing::AssignPlan.call(club: club, plan_slug: "premium_full")
|
||||
rec = described_class.new(session).call
|
||||
expect(rec.expires_at).to be > 89.days.from_now
|
||||
end
|
||||
|
||||
it "non crea recording se abbonamento scaduto" do
|
||||
Billing::AssignPlan.call(club: club, plan_slug: "premium_light")
|
||||
club.subscription.update!(status: "canceled")
|
||||
expect(described_class.new(session).call).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user