Correctly handle matches that are not started yet
This commit is contained in:
parent
424f92b135
commit
65ff6a830e
|
|
@ -48,6 +48,7 @@ class Match < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_points_of(team)
|
def group_points_of(team)
|
||||||
|
return 0 unless finished? || in_progress?
|
||||||
return 0 unless teams.include?(team)
|
return 0 unless teams.include?(team)
|
||||||
|
|
||||||
case current_leading_team
|
case current_leading_team
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,25 @@ RSpec.describe Match, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'not started match' do
|
||||||
|
before do
|
||||||
|
@not_started_match = create(:running_group_match, state: :not_started)
|
||||||
|
@team1 = @not_started_match.teams.first
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns correct group_points' do
|
||||||
|
expect(@not_started_match.group_points_of(@team1)).to be(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns correct scored_points' do
|
||||||
|
expect(@match.scored_points_of(@team1)).to be(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns correct received_points' do
|
||||||
|
expect(@match.received_points_of(@team1)).to be(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'uneven match' do
|
context 'uneven match' do
|
||||||
before do
|
before do
|
||||||
@match.match_scores.each do |ms|
|
@match.match_scores.each do |ms|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue