Fix teams not associated with created tournament

when choosing a group stage
This commit is contained in:
Thor77 2019-06-17 16:14:27 +02:00
parent f71179ee8a
commit 3109308817
2 changed files with 6 additions and 0 deletions

View File

@ -39,6 +39,8 @@ class TournamentsController < ApplicationController
if group_stage
params.require(:playoff_teams_amount)
groups = organize_teams_in_groups(teams)
# associate provided teams with tournament
tournament.teams = groups.flatten
# add groups to tournament
result = AddGroupStageToTournamentAndSave.call(tournament: tournament, groups: groups)
else

View File

@ -195,6 +195,10 @@ RSpec.describe TournamentsController, type: :controller do
.to eq(create_group_tournament_data[:playoff_teams_amount])
end
it 'associates the given teams with the created tournament' do
expect(@group_stage_tournament.teams).to match_array(@teams16)
end
context 'playoff_teams_amount unacceptable' do
shared_examples_for 'wrong playoff_teams_amount' do
it 'fails' do