Aggiunge copertina sponsor custom solo Premium Full, con override in wizard e slate sui nodi di streaming.
Permette upload da portale e app con ereditarietà partita→squadra→società, generazione MP4 via ffmpeg e distribuzione su home lab e nodi CPX per pause e assenza segnale. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Streams::CoverResolver 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!(:match) { team.matches.create!(opponent_name: "Opp", sport: "volleyball") }
|
||||
|
||||
before do
|
||||
load Rails.root.join("db/seeds/plans.rb")
|
||||
Billing::AssignPlan.call(club: club, plan_slug: "free")
|
||||
end
|
||||
|
||||
def attach_ready_cover(record, name)
|
||||
record.cover_image.attach(
|
||||
io: StringIO.new("fake-image"),
|
||||
filename: "#{name}.png",
|
||||
content_type: "image/png"
|
||||
)
|
||||
record.cover_slate.attach(
|
||||
io: StringIO.new("fake-mp4"),
|
||||
filename: "#{name}.mp4",
|
||||
content_type: "video/mp4"
|
||||
)
|
||||
path = Streams::CoverSlatePaths.expected_path(record)
|
||||
FileUtils.mkdir_p(File.dirname(path))
|
||||
File.write(path, "fake mp4")
|
||||
path
|
||||
end
|
||||
|
||||
it "restituisce default senza Premium Full" do
|
||||
resolver = described_class.new(match)
|
||||
expect(resolver.cover_source).to eq("default")
|
||||
expect(resolver.effective_cover_url).to eq("/images/copertina-canale.png")
|
||||
end
|
||||
|
||||
context "con Premium Full" do
|
||||
before { Billing::AssignPlan.call(club: club, plan_slug: "premium_full") }
|
||||
|
||||
it "preferisce partita, poi squadra, poi società" do
|
||||
attach_ready_cover(club, "club")
|
||||
attach_ready_cover(team, "team")
|
||||
attach_ready_cover(match, "match")
|
||||
|
||||
resolver = described_class.new(match)
|
||||
expect(resolver.cover_source).to eq("match")
|
||||
end
|
||||
|
||||
it "eredita dalla squadra se la partita non ha override" do
|
||||
attach_ready_cover(club, "club")
|
||||
attach_ready_cover(team, "team")
|
||||
|
||||
resolver = described_class.new(match)
|
||||
expect(resolver.cover_source).to eq("team")
|
||||
end
|
||||
|
||||
it "eredita dalla società se mancano squadra e partita" do
|
||||
attach_ready_cover(club, "club")
|
||||
|
||||
resolver = described_class.new(match)
|
||||
expect(resolver.cover_source).to eq("club")
|
||||
end
|
||||
|
||||
it "ignora cover_image senza slate MP4 pronta su disco" do
|
||||
attach_ready_cover(team, "team")
|
||||
match.cover_image.attach(io: StringIO.new("img"), filename: "m.png", content_type: "image/png")
|
||||
|
||||
resolver = described_class.new(match)
|
||||
expect(resolver.cover_source).to eq("team")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user