From 90d97962a3f6ea01943889b6c929d7fb0e5e1221 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Tue, 18 Jun 2019 16:12:18 +0200 Subject: [PATCH] Test trying to finish a group stage with unfinished matches --- spec/controllers/stages_controller_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/controllers/stages_controller_spec.rb b/spec/controllers/stages_controller_spec.rb index 773cd65..61da200 100644 --- a/spec/controllers/stages_controller_spec.rb +++ b/spec/controllers/stages_controller_spec.rb @@ -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)