Billing Stripe, link regia mobile e staff solo trasmissione.
Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,50 +1,18 @@
|
||||
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") }
|
||||
let!(:club) { Club.create!(name: "Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
|
||||
let!(:team) { club.teams.create!(name: "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
|
||||
it "limits transmission invites on free plan" do
|
||||
user = User.create!(email: "t1@test.com", name: "T1", password: "password123", role: "coach")
|
||||
UserTeam.create!(user: user, team: team, role: "member", staff_kind: "transmission")
|
||||
ent = described_class.new(team)
|
||||
expect { ent.assert_can_invite! }.to raise_error(Teams::EntitlementError, /trasmissione/)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user