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