Add GroupScore objects for every team to the group stage
This commit is contained in:
parent
e6bc0333f3
commit
f54db04eee
|
|
@ -13,7 +13,8 @@ class GroupStageService
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def generate_all_matches_between(teams)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ RSpec.describe GroupStageService do
|
|||
expect(group_stage_teams).to match_array(@groups.flatten)
|
||||
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
|
||||
unequal_groups = @groups
|
||||
unequal_groups.first.pop
|
||||
|
|
|
|||
Loading…
Reference in New Issue