Files
MatchLiveTv/backend/spec/services/teams/entitlements_spec.rb
Emiliano Frascaro 4083bc5dee Club come entità principale, branding e fix infrastruttura streaming.
Introduce clubs con abbonamento, branding Active Storage e flusso registrazione società; corregge healthcheck MediaMTX (immagine distroless) e allinea dominio produzione matchlivetv.it.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-27 09:16:24 +02:00

51 lines
1.6 KiB
Ruby

require "rails_helper"
RSpec.describe Teams::Entitlements do
let(:club) { Club.create!(name: "Test Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
let(:team) { club.teams.create!(name: "Test Team", sport: "volleyball") }
before do
load Rails.root.join("db/seeds/plans.rb")
Billing::AssignPlan.call(club: club, plan_slug: "free")
end
subject(:ent) { described_class.new(team) }
it "allows matchlivetv on free" do
expect(ent.can_stream_on?("matchlivetv")).to be true
end
it "denies youtube on free" do
expect { ent.assert_can_stream_on!("youtube") }.to raise_error(Teams::EntitlementError)
end
it "allows youtube on premium full" do
Billing::AssignPlan.call(club: club, plan_slug: "premium_full")
expect(ent.can_stream_on?("youtube")).to be true
end
it "enforces transmission staff limit on free" do
team.team_invitations.create!(
email: "camera@test.com",
token_digest: SecureRandom.hex(32),
role: "member",
staff_kind: "transmission",
expires_at: 7.days.from_now
)
expect { ent.assert_can_invite!(staff_kind: "transmission") }.to raise_error(Teams::EntitlementError) do |e|
expect(e.code).to eq("staff_limit_reached")
end
end
it "allows regia invite when only transmission slot is used on free" do
team.team_invitations.create!(
email: "camera@test.com",
token_digest: SecureRandom.hex(32),
role: "member",
staff_kind: "transmission",
expires_at: 7.days.from_now
)
expect { ent.assert_can_invite!(staff_kind: "regia") }.not_to raise_error
end
end