Merge pull request #25 from turniere/ticket/TURNIERE-129

Add tests checking generated stage
This commit is contained in:
Daniel Schädler 2019-04-09 10:58:06 +02:00 committed by GitHub
commit f223c03686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -100,6 +100,21 @@ RSpec.describe TournamentsController, type: :controller do
expect(tournament.teams).to match_array(@teams)
end
it 'generates a playoff stage' do
post :create, params: create_data
body = deserialize_response response
tournament = Tournament.find(body[:id])
expect(tournament.stages.first).to be_a(Stage)
end
it 'generates a playoff stage with all given teams' do
post :create, params: create_data
body = deserialize_response response
tournament = Tournament.find(body[:id])
included_teams = tournament.stages.first.matches.map { |m| m.match_scores.map(&:team) }.flatten.uniq
expect(included_teams).to match_array(@teams)
end
it 'renders a JSON response with the new tournament' do
post :create, params: create_data
expect(response).to have_http_status(:created)