From ce7b5c5ac77afaed5684724262b23d750f928f22 Mon Sep 17 00:00:00 2001 From: Malaber Date: Wed, 15 Apr 2026 11:22:55 +0200 Subject: [PATCH] Fix match points specs --- app/models/match.rb | 2 ++ spec/models/match_spec.rb | 42 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index 3056f60..e80697a 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -41,6 +41,7 @@ class Match < ApplicationRecord def scored_points_of(team) return 0 if decider? + return 0 unless (finished? || in_progress?) && teams.include?(team) match_score = match_score_for(team) match_score ? match_score.points : 0 @@ -48,6 +49,7 @@ class Match < ApplicationRecord def received_points_of(team) return 0 if decider? + return 0 unless (finished? || in_progress?) && teams.include?(team) opponent_match_score = opponent_match_score_for(team) opponent_match_score ? opponent_match_score.points : 0 diff --git a/spec/models/match_spec.rb b/spec/models/match_spec.rb index 6610b96..d8c4226 100644 --- a/spec/models/match_spec.rb +++ b/spec/models/match_spec.rb @@ -109,21 +109,21 @@ RSpec.describe Match, type: :model do end it 'returns correct group_points' do - expect(@match.group_points_of(@team1)).to be(1) - expect(@match.group_points_of(@team2)).to be(1) - expect(@match.group_points_of(@uninvolved_team)).to be(0) + expect(@match.group_points_of(@team1)).to eq(1) + expect(@match.group_points_of(@team2)).to eq(1) + expect(@match.group_points_of(@uninvolved_team)).to eq(0) end it 'returns correct scored_points' do - expect(@match.scored_points_of(@team1)).to be(34) - expect(@match.scored_points_of(@team2)).to be(34) - expect(@match.scored_points_of(@uninvolved_team)).to be(0) + expect(@match.scored_points_of(@team1)).to eq(34) + expect(@match.scored_points_of(@team2)).to eq(34) + expect(@match.scored_points_of(@uninvolved_team)).to eq(0) end it 'returns correct received_points' do - expect(@match.received_points_of(@team1)).to be(34) - expect(@match.received_points_of(@team2)).to be(34) - expect(@match.received_points_of(@uninvolved_team)).to be(0) + expect(@match.received_points_of(@team1)).to eq(34) + expect(@match.received_points_of(@team2)).to eq(34) + expect(@match.received_points_of(@uninvolved_team)).to eq(0) end end @@ -134,15 +134,15 @@ RSpec.describe Match, type: :model do end it 'returns correct group_points' do - expect(@not_started_match.group_points_of(@team1)).to be(0) + expect(@not_started_match.group_points_of(@team1)).to eq(0) end it 'returns correct scored_points' do - expect(@match.scored_points_of(@team1)).to be(0) + expect(@not_started_match.scored_points_of(@team1)).to eq(0) end it 'returns correct received_points' do - expect(@match.received_points_of(@team1)).to be(0) + expect(@not_started_match.received_points_of(@team1)).to eq(0) end end @@ -155,21 +155,21 @@ RSpec.describe Match, type: :model do end it 'returns correct group_points' do - expect(@match.group_points_of(@team1)).to be(3) - expect(@match.group_points_of(@team2)).to be(0) - expect(@match.group_points_of(@uninvolved_team)).to be(0) + expect(@match.group_points_of(@team1)).to eq(3) + expect(@match.group_points_of(@team2)).to eq(0) + expect(@match.group_points_of(@uninvolved_team)).to eq(0) end it 'returns correct scored_points' do - expect(@match.scored_points_of(@team1)).to be(42) - expect(@match.scored_points_of(@team2)).to be(17) - expect(@match.scored_points_of(@uninvolved_team)).to be(0) + expect(@match.scored_points_of(@team1)).to eq(42) + expect(@match.scored_points_of(@team2)).to eq(17) + expect(@match.scored_points_of(@uninvolved_team)).to eq(0) end it 'returns correct received_points' do - expect(@match.received_points_of(@team1)).to be(17) - expect(@match.received_points_of(@team2)).to be(42) - expect(@match.received_points_of(@uninvolved_team)).to be(0) + expect(@match.received_points_of(@team1)).to eq(17) + expect(@match.received_points_of(@team2)).to eq(42) + expect(@match.received_points_of(@uninvolved_team)).to eq(0) end end end