Test returning unprocessable entity when error occurs in match population

This commit is contained in:
Daniel Schädler 2019-06-04 23:39:34 +02:00
parent 0d85c057b6
commit 0c64839319
1 changed files with 17 additions and 0 deletions

View File

@ -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