From 05736519194712375fcd3b35d278bb9fc6831a84 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Sat, 11 May 2019 17:15:23 +0200 Subject: [PATCH] Check for errors while populating the match below --- app/controllers/matches_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 28ee8ed..322387a 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -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