diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index c65b521..0d444fa 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -15,7 +15,7 @@ class MatchesController < ApplicationController new_state = match_params['state'] if new_state == 'finished' # implement logic to move the winning team into the next stage - match_params['state'] = 'team1_won' # or 'team2_won' or 'undecided' + match_params['state'] = 'finished' # or 'team2_won' or 'undecided' render json: {}, status: :not_implemented end if @match.update(match_params) diff --git a/app/models/match.rb b/app/models/match.rb index 8b3ba33..8007619 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Match < ApplicationRecord - enum state: %i[single_team not_ready not_started in_progress team1_won team2_won undecided] + enum state: %i[single_team not_ready not_started in_progress finished undecided] belongs_to :stage, optional: true belongs_to :group, optional: true diff --git a/spec/controllers/matches_controller_spec.rb b/spec/controllers/matches_controller_spec.rb index 10b0a30..c75a1c5 100644 --- a/spec/controllers/matches_controller_spec.rb +++ b/spec/controllers/matches_controller_spec.rb @@ -32,7 +32,7 @@ RSpec.describe MatchesController, type: :controller do let(:invalid_update) do { - state: 'team1_won' + state: 'finished' } end diff --git a/spec/factories/matches.rb b/spec/factories/matches.rb index 030c87c..43fb55d 100644 --- a/spec/factories/matches.rb +++ b/spec/factories/matches.rb @@ -27,7 +27,7 @@ FactoryBot.define do # random number generated by blapplications match.match_scores.first.points += 1 end - state { :team1_won } + state { :finished } end end @@ -51,7 +51,7 @@ FactoryBot.define do after(:create) do |match, evaluator| match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3) end - state { :team1_won } + state { :finished } end end end diff --git a/spec/interactors/add_playoffs_to_tournament_interactor_spec.rb b/spec/interactors/add_playoffs_to_tournament_interactor_spec.rb index 056dc2b..884f0e8 100644 --- a/spec/interactors/add_playoffs_to_tournament_interactor_spec.rb +++ b/spec/interactors/add_playoffs_to_tournament_interactor_spec.rb @@ -14,10 +14,10 @@ RSpec.describe AddPlayoffsToTournament do end before do - @group_stage_tournament = create(:stage_tournament) - @playoff_stage_tournament = create(:tournament) - @full_tournament = create(:stage_tournament, stage_count: 5) - @stages = create_list(:stage, 5) + @group_stage_tournament = create(:group_stage_only_tournament, group_count: 0) + @playoff_stage_tournament = create(:stageless_tournament) + @full_tournament = create(:dummy_stage_tournament) + @stages = create_list(:stage, 3) end context 'PlayoffStageService mocked' do