Check for errors while populating the match below

This commit is contained in:
Daniel Schädler 2019-05-11 17:15:23 +02:00
parent fc69c6e6e6
commit 12daf53599
1 changed files with 5 additions and 1 deletions

View File

@ -14,7 +14,11 @@ class MatchesController < ApplicationController
def update
new_state = match_params['state']
if new_state == 'finished'
PopulateMatchBelowAndSave.call(match:@match) unless @match.group_match?
result = PopulateMatchBelowAndSave.call(match: @match) unless @match.group_match?
unless result.success?
render json: { error: 'Moving Team one stage down failed' }, status: :unprocessable_entity
return
end
end
if @match.update(match_params)
render json: @match