Distruggendo la sessione ora si elimina anche il recording, evitando la violazione FK su recordings. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.4 KiB
Ruby
38 lines
1.4 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Public match destroy with recording", type: :request do
|
|
let!(:user) { User.create!(email: "match-del@test.it", name: "Del", password: "Password123", role: "coach") }
|
|
let!(:club) { Club.create!(name: "Del Club", sport: "pallavolo", primary_color: "#e53935", secondary_color: "#ffffff") }
|
|
let!(:team) { club.teams.create!(name: "U14", sport: "pallavolo") }
|
|
let!(:match) { team.matches.create!(opponent_name: "Rival", sport: "pallavolo") }
|
|
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",
|
|
storage_backend: "local",
|
|
storage_policy: "retained",
|
|
privacy_status: "unlisted"
|
|
)
|
|
end
|
|
|
|
before do
|
|
ClubMembership.create!(user: user, club: club, role: "owner")
|
|
UserTeam.create!(user: user, team: team, role: "member", staff_kind: "transmission")
|
|
post public_login_path, params: { email: user.email, password: "Password123" }
|
|
end
|
|
|
|
it "cancella la partita anche se esiste un recording collegato alla sessione" do
|
|
expect do
|
|
delete public_team_match_path(team, match)
|
|
end.to change(Match, :count).by(-1)
|
|
.and change(StreamSession, :count).by(-1)
|
|
.and change(Recording, :count).by(-1)
|
|
|
|
expect(response).to redirect_to(public_team_matches_path(team))
|
|
end
|
|
end
|