Change status of Match to only represent being finished

The winner will be a attribute of the Match instead of something
that is written in its status.
This commit is contained in:
Daniel Schädler 2019-05-08 21:57:12 +02:00
parent 1a2caaedef
commit 280b0c1dec
5 changed files with 9 additions and 9 deletions

View File

@ -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)

View File

@ -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

View File

@ -32,7 +32,7 @@ RSpec.describe MatchesController, type: :controller do
let(:invalid_update) do
{
state: 'team1_won'
state: 'finished'
}
end

View File

@ -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

View File

@ -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