Test trying to finish a group stage with unfinished matches

This commit is contained in:
Daniel Schädler 2019-06-18 16:12:18 +02:00
parent fd8ff20ce8
commit 90d97962a3
1 changed files with 20 additions and 0 deletions

View File

@ -74,6 +74,26 @@ RSpec.describe StagesController, type: :controller do
end
end
context 'trying to finish a group stage with unfinished matches' do
let(:group_stage) do
create(:group_stage)
end
before do
apply_authentication_headers_for group_stage.owner
put :update, params: { id: group_stage.to_param }.merge(state: 'finished')
end
it 'it returns unprocessable entity' do
expect(response).to have_http_status(:unprocessable_entity)
end
it 'returns the correct error' do
expect(deserialize_response(response)[:error])
.to eq('Group Stage still has some matches that are not over yet. Finish them to generate playoffs')
end
end
context 'already finished group stage' do
let(:finished_group_stage) do
group_stage = create(:group_stage, match_factory: :finished_group_match)