diff --git a/spec/controllers/matches_controller_spec.rb b/spec/controllers/matches_controller_spec.rb index f1721cd..8c6187a 100644 --- a/spec/controllers/matches_controller_spec.rb +++ b/spec/controllers/matches_controller_spec.rb @@ -158,6 +158,23 @@ RSpec.describe MatchesController, type: :controller do expect(response).to have_http_status(:unprocessable_entity) end end + + context 'PopulateMatchBelowAndSave fails' do + before do + @playoff_match = create(:running_playoff_match) + expect(PopulateMatchBelowAndSave).to receive(:call).once.with(match: @playoff_match) + .and_return(context) + end + + context 'when unsuccessful' do + let(:context) { double(:context, success?: false) } + + it 'returns unprocessable entity' do + put :update, params: { id: @playoff_match.to_param }.merge(finished) + expect(response).to have_http_status(:unprocessable_entity) + end + end + end end end