Merge pull request #63 from turniere/ticket/TURNIERE-253
Fix teams not associated with created tournament
This commit is contained in:
commit
b57c2498c3
|
|
@ -41,6 +41,8 @@ class TournamentsController < ApplicationController
|
||||||
groups = organize_teams_in_groups(teams)
|
groups = organize_teams_in_groups(teams)
|
||||||
# add groups to tournament
|
# add groups to tournament
|
||||||
result = AddGroupStageToTournamentAndSave.call(tournament: tournament, groups: groups)
|
result = AddGroupStageToTournamentAndSave.call(tournament: tournament, groups: groups)
|
||||||
|
# associate provided teams with tournament on success
|
||||||
|
tournament.teams = groups.flatten if result.success?
|
||||||
else
|
else
|
||||||
# convert teams parameter into Team objects
|
# convert teams parameter into Team objects
|
||||||
teams = teams.map(&method(:find_or_create_team))
|
teams = teams.map(&method(:find_or_create_team))
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,10 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
.to eq(create_group_tournament_data[:playoff_teams_amount])
|
.to eq(create_group_tournament_data[:playoff_teams_amount])
|
||||||
end
|
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
|
context 'playoff_teams_amount unacceptable' do
|
||||||
shared_examples_for 'wrong playoff_teams_amount' do
|
shared_examples_for 'wrong playoff_teams_amount' do
|
||||||
it 'fails' do
|
it 'fails' do
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue