Reorganize group_stage=true tests
This commit is contained in:
parent
0eff3d382d
commit
793f750547
|
|
@ -215,7 +215,8 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
expect(included_teams).to match_array(@teams4)
|
expect(included_teams).to match_array(@teams4)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with parameter group_stage=true and groups of 4' do
|
context 'with parameter group_stage=true' do
|
||||||
|
context 'with groups of 4' do
|
||||||
before do
|
before do
|
||||||
post :create, params: create_group_tournament_data_groups_of_4
|
post :create, params: create_group_tournament_data_groups_of_4
|
||||||
body = deserialize_response response
|
body = deserialize_response response
|
||||||
|
|
@ -244,6 +245,38 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
it 'associates the given teams with the created tournament' do
|
it 'associates the given teams with the created tournament' do
|
||||||
expect(@group_stage_tournament.teams).to match_array(@teams16)
|
expect(@group_stage_tournament.teams).to match_array(@teams16)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'groups of 5' do
|
||||||
|
before do
|
||||||
|
post :create, params: create_group_tournament_data_groups_of_5
|
||||||
|
body = deserialize_response response
|
||||||
|
@group_stage_tournament = Tournament.find(body[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns HTTP status created' do
|
||||||
|
expect(response).to have_http_status(:created)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'generates a group stage with all teams given in parameters' do
|
||||||
|
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
|
||||||
|
expect(included_teams).to match_array(@teams20)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'generates a group stage' do
|
||||||
|
group_stage = @group_stage_tournament.stages.find_by(level: -1)
|
||||||
|
expect(group_stage).to be_a(Stage)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'saves the amount of teams that advance into playoffs' do
|
||||||
|
expect(@group_stage_tournament.playoff_teams_amount)
|
||||||
|
.to eq(create_group_tournament_data_groups_of_5[:playoff_teams_amount])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'associates the given teams with the created tournament' do
|
||||||
|
expect(@group_stage_tournament.teams).to match_array(@teams20)
|
||||||
|
end
|
||||||
|
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
|
||||||
|
|
@ -282,37 +315,6 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with parameter group_stage=true and groups of 5' do
|
|
||||||
before do
|
|
||||||
post :create, params: create_group_tournament_data_groups_of_5
|
|
||||||
body = deserialize_response response
|
|
||||||
@group_stage_tournament = Tournament.find(body[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns HTTP status created' do
|
|
||||||
expect(response).to have_http_status(:created)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'generates a group stage with all teams given in parameters' do
|
|
||||||
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
|
|
||||||
expect(included_teams).to match_array(@teams20)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'generates a group stage' do
|
|
||||||
group_stage = @group_stage_tournament.stages.find_by(level: -1)
|
|
||||||
expect(group_stage).to be_a(Stage)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves the amount of teams that advance into playoffs' do
|
|
||||||
expect(@group_stage_tournament.playoff_teams_amount)
|
|
||||||
.to eq(create_group_tournament_data_groups_of_5[:playoff_teams_amount])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'associates the given teams with the created tournament' do
|
|
||||||
expect(@group_stage_tournament.teams).to match_array(@teams20)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'renders a JSON response with the new tournament' do
|
it 'renders a JSON response with the new tournament' do
|
||||||
post :create, params: create_playoff_tournament_data_4_teams
|
post :create, params: create_playoff_tournament_data_4_teams
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue