Add GroupScore objects for every team to the group stage
This commit is contained in:
parent
3c98fd0545
commit
037c9ebcf1
|
|
@ -13,7 +13,8 @@ class GroupStageService
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_group_object_from(team_array)
|
def get_group_object_from(team_array)
|
||||||
Group.new matches: generate_all_matches_between(team_array)
|
Group.new matches: generate_all_matches_between(team_array),
|
||||||
|
group_scores: team_array.map { |team| GroupScore.new team: team }
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_all_matches_between(teams)
|
def generate_all_matches_between(teams)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@ RSpec.describe GroupStageService do
|
||||||
expect(group_stage_teams).to match_array(@groups.flatten)
|
expect(group_stage_teams).to match_array(@groups.flatten)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'adds GroupScore objects for every team present in the group' do
|
||||||
|
group_stage = GroupStageService.generate_group_stage(@groups)
|
||||||
|
teams_in_group_scores = group_stage.groups.map { |g| g.group_scores.map(&:team) }.flatten
|
||||||
|
expect(teams_in_group_scores).to match_array(@groups.flatten)
|
||||||
|
end
|
||||||
|
|
||||||
it 'raises exception when given different sizes of groups' do
|
it 'raises exception when given different sizes of groups' do
|
||||||
unequal_groups = @groups
|
unequal_groups = @groups
|
||||||
unequal_groups.first.pop
|
unequal_groups.first.pop
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue