Correctly handle matches that are not started yet
This commit is contained in:
parent
9e4d506e66
commit
5406f393d3
|
|
@ -48,6 +48,7 @@ class Match < ApplicationRecord
|
|||
end
|
||||
|
||||
def group_points_of(team)
|
||||
return 0 unless finished? || in_progress?
|
||||
return 0 unless teams.include?(team)
|
||||
|
||||
case current_leading_team
|
||||
|
|
|
|||
|
|
@ -126,6 +126,25 @@ RSpec.describe Match, type: :model do
|
|||
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
|
||||
before do
|
||||
@match.match_scores.each do |ms|
|
||||
|
|
|
|||
Loading…
Reference in New Issue