From 142c7c3d536001fdb32c75f8d70954a5c79dbc7a Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Fri, 7 Jun 2019 00:29:35 +0200 Subject: [PATCH] Create a new match to hopefully fix random failure of this test --- spec/controllers/matches_controller_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/controllers/matches_controller_spec.rb b/spec/controllers/matches_controller_spec.rb index 0078b61..bd9d748 100644 --- a/spec/controllers/matches_controller_spec.rb +++ b/spec/controllers/matches_controller_spec.rb @@ -161,15 +161,20 @@ RSpec.describe MatchesController, type: :controller do context 'PopulateMatchBelowAndSave fails' do before do - expect(PopulateMatchBelowAndSave).to receive(:call).once.with(match: @running_playoff_match) + @running_match = create(:running_playoff_match) + expect(PopulateMatchBelowAndSave).to receive(:call).once.with(match: @running_match) .and_return(context) end context 'when unsuccessful' do + before(:each) do + apply_authentication_headers_for @running_match.owner + end + let(:context) { double(:context, success?: false) } it 'returns unprocessable entity' do - put :update, params: { id: @running_playoff_match.to_param }.merge(finished) + put :update, params: { id: @running_match.to_param }.merge(finished) expect(response).to have_http_status(:unprocessable_entity) end end