HTTP response Test should not fail because of no tournament found
This commit is contained in:
parent
793f750547
commit
c93244b005
|
|
@ -219,62 +219,72 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
context 'with groups of 4' 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
|
|
||||||
@group_stage_tournament = Tournament.find(body[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns HTTP status created' do
|
it 'returns HTTP status created' do
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates a group stage with all teams given in parameters' do
|
context 'looking at the tournament' do
|
||||||
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
|
before do
|
||||||
expect(included_teams).to match_array(@teams16)
|
body = deserialize_response response
|
||||||
end
|
@group_stage_tournament = Tournament.find(body[:id])
|
||||||
|
end
|
||||||
|
|
||||||
it 'generates a group stage' do
|
it 'generates a group stage with all teams given in parameters' do
|
||||||
group_stage = @group_stage_tournament.stages.find_by(level: -1)
|
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
|
||||||
expect(group_stage).to be_a(Stage)
|
expect(included_teams).to match_array(@teams16)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves the amount of teams that advance into playoffs' do
|
it 'generates a group stage' do
|
||||||
expect(@group_stage_tournament.playoff_teams_amount)
|
group_stage = @group_stage_tournament.stages.find_by(level: -1)
|
||||||
.to eq(create_group_tournament_data_groups_of_4[:playoff_teams_amount])
|
expect(group_stage).to be_a(Stage)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'associates the given teams with the created tournament' do
|
it 'saves the amount of teams that advance into playoffs' do
|
||||||
expect(@group_stage_tournament.teams).to match_array(@teams16)
|
expect(@group_stage_tournament.playoff_teams_amount)
|
||||||
|
.to eq(create_group_tournament_data_groups_of_4[:playoff_teams_amount])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'associates the given teams with the created tournament' do
|
||||||
|
expect(@group_stage_tournament.teams).to match_array(@teams16)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'groups of 5' do
|
context 'groups of 5' do
|
||||||
before do
|
before do
|
||||||
post :create, params: create_group_tournament_data_groups_of_5
|
post :create, params: create_group_tournament_data_groups_of_5
|
||||||
body = deserialize_response response
|
|
||||||
@group_stage_tournament = Tournament.find(body[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns HTTP status created' do
|
it 'returns HTTP status created' do
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates a group stage with all teams given in parameters' do
|
context 'looking at the tournament' do
|
||||||
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
|
before do
|
||||||
expect(included_teams).to match_array(@teams20)
|
body = deserialize_response response
|
||||||
end
|
@group_stage_tournament = Tournament.find(body[:id])
|
||||||
|
end
|
||||||
|
|
||||||
it 'generates a group stage' do
|
it 'generates a group stage with all teams given in parameters' do
|
||||||
group_stage = @group_stage_tournament.stages.find_by(level: -1)
|
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
|
||||||
expect(group_stage).to be_a(Stage)
|
expect(included_teams).to match_array(@teams20)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves the amount of teams that advance into playoffs' do
|
it 'generates a group stage' do
|
||||||
expect(@group_stage_tournament.playoff_teams_amount)
|
group_stage = @group_stage_tournament.stages.find_by(level: -1)
|
||||||
.to eq(create_group_tournament_data_groups_of_5[:playoff_teams_amount])
|
expect(group_stage).to be_a(Stage)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'associates the given teams with the created tournament' do
|
it 'saves the amount of teams that advance into playoffs' do
|
||||||
expect(@group_stage_tournament.teams).to match_array(@teams20)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue