Aggiunge gestione archivio replay nel pannello admin.

Gli admin possono vedere, modificare ed eliminare i replay di una società come la squadra proprietaria, riusando la stessa UI e logica dell'archivio pubblico.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-13 09:01:38 +02:00
parent da75582dae
commit 89854869c7
15 changed files with 455 additions and 219 deletions

View File

@@ -0,0 +1,50 @@
require "rails_helper"
RSpec.describe "Admin club replays", type: :request do
let!(:admin) { AdminAccount.create!(username: "ops", password: "secret123") }
let!(:club) { Club.create!(name: "Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
let!(:team) { club.teams.create!(name: "Tigers", 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.ago) }
let!(:session) do
StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "ended", ended_at: 1.hour.ago)
end
let!(:recording) do
Recording.create!(
stream_session: session, team: team, status: "ready", privacy_status: "public",
title: "Finale",
storage_key: "teams/#{team.id}/sessions/#{session.id}/replay.mp4",
expires_at: 30.days.from_now
)
end
before do
post admin_login_path, params: { username: "ops", password: "secret123" }
end
it "mostra l'archivio replay della società" do
get admin_club_recordings_path(club)
expect(response).to have_http_status(:ok)
expect(response.body).to include("Archivio Replay")
expect(response.body).to include("Finale")
expect(response.body).to include("Tigers")
end
it "aggiorna titolo e privacy" do
patch admin_club_recording_path(club, recording), params: { recording: { title: "Nuovo titolo", privacy_status: "unlisted" } }
expect(response).to redirect_to(admin_club_recordings_path(club))
recording.reload
expect(recording.title).to eq("Nuovo titolo")
expect(recording.privacy_status).to eq("unlisted")
end
it "elimina un replay" do
delete admin_club_recording_path(club, recording)
expect(response).to redirect_to(admin_club_recordings_path(club))
expect(recording.reload.status).to eq("expired")
expect(recording.deleted_at).to be_present
end
end

View File

@@ -0,0 +1,36 @@
require "rails_helper"
RSpec.describe Recordings::ClubArchive do
let!(:club) { Club.create!(name: "Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
let!(:team_a) { club.teams.create!(name: "A", sport: "volleyball") }
let!(:team_b) { club.teams.create!(name: "B", sport: "volleyball") }
let!(:user) { User.create!(email: "coach@test.com", name: "Coach", password: "password123", role: "coach") }
let!(:match_a) { team_a.matches.create!(opponent_name: "Rival A", scheduled_at: 1.day.ago) }
let!(:match_b) { team_b.matches.create!(opponent_name: "Rival B", scheduled_at: 1.day.ago) }
let!(:session_a) do
StreamSession.create!(match: match_a, user: user, platform: "matchlivetv", status: "ended", ended_at: 1.hour.ago)
end
let!(:session_b) do
StreamSession.create!(match: match_b, user: user, platform: "matchlivetv", status: "ended", ended_at: 1.hour.ago)
end
let!(:ready_a) do
Recording.create!(
stream_session: session_a, team: team_a, status: "ready", privacy_status: "public",
storage_key: "teams/#{team_a.id}/sessions/#{session_a.id}/replay.mp4",
expires_at: 30.days.from_now
)
end
let!(:processing_b) do
Recording.create!(stream_session: session_b, team: team_b, status: "processing", privacy_status: "unlisted")
end
it "filtra per squadra" do
archive = described_class.new(club, params: { team_id: team_a.id })
expect(archive.recordings).to contain_exactly(ready_a)
end
it "filtra per stato ready" do
archive = described_class.new(club, params: { status: "ready" })
expect(archive.recordings).to contain_exactly(ready_a)
end
end