From aac0bcb8c8957dcbadde233405693c7bfb6606dc Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Sat, 11 May 2019 16:43:04 +0200 Subject: [PATCH] Test stopping of matches --- spec/controllers/matches_controller_spec.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/spec/controllers/matches_controller_spec.rb b/spec/controllers/matches_controller_spec.rb index af73137..b5116bd 100644 --- a/spec/controllers/matches_controller_spec.rb +++ b/spec/controllers/matches_controller_spec.rb @@ -80,11 +80,21 @@ RSpec.describe MatchesController, type: :controller do apply_authentication_headers_for @running_playoff_match_owner end - it 'stops the match' do - put :update, params: { id: @running_playoff_match.to_param }.merge(finished) - @running_playoff_match.reload - expect(response).to be_successful - expect(@running_playoff_match.state).to eq(finished[:state]) + context 'stops the match' do + before do + put :update, params: { id: @running_playoff_match.to_param }.merge(finished) + @running_playoff_match.reload + end + + it 'updates the matches status' do + expect(response).to be_successful + expect(@running_playoff_match.state).to eq(finished[:state]) + end + + it 'fills the match below' do + match_below = @tournament.stages.find { |s| s.level == 2 }.matches.find { |m| m.position == @running_playoff_match.position / 2 }.reload + expect(match_below.teams).to include(@running_playoff_match.winner) + end end end