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:
2026-05-26 17:45:37 +02:00
commit bba6df52c0
381 changed files with 20599 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rspec/rails"
RSpec.configure do |config|
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
end

View File

@@ -0,0 +1,16 @@
require "rails_helper"
RSpec.describe "Auth API", type: :request do
let!(:user) { User.create!(email: "test@example.com", name: "Test", password: "password123", role: "coach") }
it "logs in with valid credentials" do
post "/api/v1/auth/login", params: { email: user.email, password: "password123" }
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to have_key("access_token")
end
it "rejects invalid credentials" do
post "/api/v1/auth/login", params: { email: user.email, password: "wrong" }
expect(response).to have_http_status(:unauthorized)
end
end

View 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

View 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

View File

@@ -0,0 +1,5 @@
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
end