Initial commit: monorepo Match Live TV.
Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
49
backend/spec/services/teams/entitlements_spec.rb
Normal file
49
backend/spec/services/teams/entitlements_spec.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Teams::Entitlements do
|
||||
let(:team) { Team.create!(name: "Test Team", sport: "volleyball") }
|
||||
|
||||
before do
|
||||
load Rails.root.join("db/seeds/plans.rb")
|
||||
Billing::AssignPlan.call(team: team, 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(team: team, 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
|
||||
24
backend/spec/services/webhooks/mediamtx_handler_spec.rb
Normal file
24
backend/spec/services/webhooks/mediamtx_handler_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Webhooks::MediamtxHandler do
|
||||
let(:user) { User.create!(email: "c@test.com", name: "C", password: "password123", role: "coach") }
|
||||
let(:team) { Team.create!(name: "T") }
|
||||
let!(:match) { team.matches.create!(opponent_name: "Away") }
|
||||
let!(:session) do
|
||||
StreamSession.create!(
|
||||
match: match, user: user, status: "live", platform: "youtube",
|
||||
publish_token: "tok", started_at: Time.current
|
||||
)
|
||||
end
|
||||
|
||||
it "transitions to reconnecting on disconnect" do
|
||||
described_class.new(event: "disconnect", session_id: session.id).call
|
||||
expect(session.reload.status).to eq("reconnecting")
|
||||
end
|
||||
|
||||
it "returns to live on reconnect" do
|
||||
session.update!(status: "reconnecting")
|
||||
described_class.new(event: "connect", session_id: session.id).call
|
||||
expect(session.reload.status).to eq("live")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user