Allinea hub partite app nativa e API match al wizard semplificato.
Filtra le partite visibili lato client/server, corregge il parsing date Rails su Android, semplifica lo step Partita del wizard e restringe l'API ai campi effettivamente usati (campionato, set e scoring_rules). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ RSpec.describe Match, "scheduling scopes" do
|
||||
Club.create!(name: "Sched Club", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff")
|
||||
end
|
||||
let!(:team) { club.teams.create!(name: "U16", sport: "volleyball") }
|
||||
let!(:user) { User.create!(email: "coach@test.com", name: "Coach", password: "password123", role: "coach") }
|
||||
|
||||
it "scheduled_for_live esclude partite già passate oggi" do
|
||||
past = team.matches.create!(opponent_name: "Past", scheduled_at: 2.hours.ago, sets_to_win: 3)
|
||||
@@ -13,4 +14,75 @@ RSpec.describe Match, "scheduling scopes" do
|
||||
expect(described_class.scheduled_for_live).to include(future)
|
||||
expect(described_class.scheduled_for_live).not_to include(past)
|
||||
end
|
||||
|
||||
describe "#coach_hub_visible?" do
|
||||
it "mostra diretta attiva da riprendere" do
|
||||
match = team.matches.create!(opponent_name: "Live", sets_to_win: 3)
|
||||
StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "paused")
|
||||
|
||||
expect(match.coach_hub_visible?).to be(true)
|
||||
end
|
||||
|
||||
it "mostra wizard in corso (sessione idle)" do
|
||||
match = team.matches.create!(opponent_name: "Setup", sets_to_win: 3)
|
||||
StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "idle")
|
||||
|
||||
expect(match.coach_hub_visible?).to be(true)
|
||||
end
|
||||
|
||||
it "mostra partita programmata futura mai trasmessa" do
|
||||
match = team.matches.create!(
|
||||
opponent_name: "Future",
|
||||
scheduled_at: 2.hours.from_now,
|
||||
sets_to_win: 3
|
||||
)
|
||||
|
||||
expect(match.coach_hub_visible?).to be(true)
|
||||
end
|
||||
|
||||
it "nasconde bozza abbandonata senza sessione" do
|
||||
match = team.matches.create!(opponent_name: "Avversario", sets_to_win: 3)
|
||||
|
||||
expect(match.coach_hub_visible?).to be(false)
|
||||
end
|
||||
|
||||
it "nasconde partita già trasmessa e terminata" do
|
||||
match = team.matches.create!(opponent_name: "Done", sets_to_win: 3)
|
||||
StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "ended")
|
||||
|
||||
expect(match.coach_hub_visible?).to be(false)
|
||||
end
|
||||
|
||||
it "nasconde partita programmata nel passato mai trasmessa" do
|
||||
match = team.matches.create!(
|
||||
opponent_name: "Missed",
|
||||
scheduled_at: 2.hours.ago,
|
||||
sets_to_win: 3
|
||||
)
|
||||
|
||||
expect(match.coach_hub_visible?).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe "scoring_rules" do
|
||||
it "accetta regole personalizzate valide" do
|
||||
match = team.matches.new(
|
||||
opponent_name: "Opp",
|
||||
sets_to_win: 2,
|
||||
scoring_rules: { points_per_set: 21, points_deciding_set: 15, min_point_lead: 2 }
|
||||
)
|
||||
|
||||
expect(match).to be_valid
|
||||
end
|
||||
|
||||
it "rifiuta punteggi non positivi" do
|
||||
match = team.matches.new(
|
||||
opponent_name: "Opp",
|
||||
scoring_rules: { points_per_set: 0 }
|
||||
)
|
||||
|
||||
expect(match).not_to be_valid
|
||||
expect(match.errors[:scoring_rules]).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user