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:
parent
1a2caaedef
commit
280b0c1dec
|
|
@ -15,7 +15,7 @@ class MatchesController < ApplicationController
|
||||||
new_state = match_params['state']
|
new_state = match_params['state']
|
||||||
if new_state == 'finished'
|
if new_state == 'finished'
|
||||||
# implement logic to move the winning team into the next stage
|
# 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
|
render json: {}, status: :not_implemented
|
||||||
end
|
end
|
||||||
if @match.update(match_params)
|
if @match.update(match_params)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Match < ApplicationRecord
|
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 :stage, optional: true
|
||||||
belongs_to :group, optional: true
|
belongs_to :group, optional: true
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ RSpec.describe MatchesController, type: :controller do
|
||||||
|
|
||||||
let(:invalid_update) do
|
let(:invalid_update) do
|
||||||
{
|
{
|
||||||
state: 'team1_won'
|
state: 'finished'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ FactoryBot.define do
|
||||||
# random number generated by blapplications
|
# random number generated by blapplications
|
||||||
match.match_scores.first.points += 1
|
match.match_scores.first.points += 1
|
||||||
end
|
end
|
||||||
state { :team1_won }
|
state { :finished }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ FactoryBot.define do
|
||||||
after(:create) do |match, evaluator|
|
after(:create) do |match, evaluator|
|
||||||
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3)
|
match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3)
|
||||||
end
|
end
|
||||||
state { :team1_won }
|
state { :finished }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ RSpec.describe AddPlayoffsToTournament do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@group_stage_tournament = create(:stage_tournament)
|
@group_stage_tournament = create(:group_stage_only_tournament, group_count: 0)
|
||||||
@playoff_stage_tournament = create(:tournament)
|
@playoff_stage_tournament = create(:stageless_tournament)
|
||||||
@full_tournament = create(:stage_tournament, stage_count: 5)
|
@full_tournament = create(:dummy_stage_tournament)
|
||||||
@stages = create_list(:stage, 5)
|
@stages = create_list(:stage, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'PlayoffStageService mocked' do
|
context 'PlayoffStageService mocked' do
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue