fix(ci): restore Rails 8 spec suite
Confirm factory users for real Devise auth in request specs and use Rails 8-compatible status and route calls to remove deprecation warnings.
This commit is contained in:
parent
8855532660
commit
6df5cb2502
|
|
@ -36,7 +36,7 @@ class BeamersController < ApplicationController
|
|||
push_sync_if_needed!
|
||||
render json: beamer, status: :created
|
||||
else
|
||||
render json: beamer.errors, status: :unprocessable_entity
|
||||
render json: beamer.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ class BeamersController < ApplicationController
|
|||
push_sync_if_needed!
|
||||
render json: @beamer
|
||||
else
|
||||
render json: @beamer.errors, status: :unprocessable_entity
|
||||
render json: @beamer.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ class BetsController < ApplicationController
|
|||
end
|
||||
|
||||
def handle_user_service_error(exception)
|
||||
render json: { error: exception.message }, status: :unprocessable_entity
|
||||
render json: { error: exception.message }, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class MatchScoresController < ApplicationController
|
|||
TournamentLiveBroadcast.call(@match_score.tournament.id)
|
||||
render json: @match_score
|
||||
else
|
||||
render json: @match_score.errors, status: :unprocessable_entity
|
||||
render json: @match_score.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@ class MatchesController < ApplicationController
|
|||
match = build_decider_match
|
||||
|
||||
if match.errors.any?
|
||||
render json: match.errors, status: :unprocessable_entity
|
||||
render json: match.errors, status: :unprocessable_content
|
||||
elsif match.save
|
||||
UpdateGroupsGroupScoresAndSave.call(group: @group)
|
||||
push_sync_if_needed!(@group.tournament)
|
||||
TournamentLiveBroadcast.call(@group.tournament.id)
|
||||
render json: match, include: %w[match_scores.team group], status: :created
|
||||
else
|
||||
render json: match.errors, status: :unprocessable_entity
|
||||
render json: match.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class MatchesController < ApplicationController
|
|||
render json: @match
|
||||
synced_tournament = @match.tournament
|
||||
else
|
||||
render json: @match.errors, status: :unprocessable_entity
|
||||
render json: @match.errors, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
|
@ -66,7 +66,7 @@ class MatchesController < ApplicationController
|
|||
# PATCH /matches/1/swap
|
||||
def swap
|
||||
unless @match.swappable_with?(@swap_target)
|
||||
render json: { error: 'Matches must be different group matches from the same group' }, status: :unprocessable_entity
|
||||
render json: { error: 'Matches must be different group matches from the same group' }, status: :unprocessable_content
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -102,27 +102,27 @@ class MatchesController < ApplicationController
|
|||
|
||||
if @match.winner.nil?
|
||||
render json: { error: 'Stopping undecided Matches isn\'t allowed in playoff stage' },
|
||||
status: :unprocessable_entity
|
||||
status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
return if PopulateMatchBelowAndSave.call(match: @match).success?
|
||||
|
||||
render json: { error: 'Moving Team one stage down failed' },
|
||||
status: :unprocessable_entity
|
||||
status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
def validate_params
|
||||
case match_params['state']
|
||||
when 'in_progress'
|
||||
render json: { error: 'Match can\'t start in this state' }, status: :unprocessable_entity \
|
||||
render json: { error: 'Match can\'t start in this state' }, status: :unprocessable_content \
|
||||
unless @match.not_started?
|
||||
when 'finished'
|
||||
render json: { error: 'Match can\'t finish in this state' }, status: :unprocessable_entity \
|
||||
render json: { error: 'Match can\'t finish in this state' }, status: :unprocessable_content \
|
||||
unless @match.in_progress?
|
||||
else
|
||||
render json: { error: 'Invalid target state' }, status: :unprocessable_entity
|
||||
render json: { error: 'Invalid target state' }, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class StagesController < ApplicationController
|
|||
def update
|
||||
if stage_params[:state] == 'finished'
|
||||
unless @stage.state == 'in_progress'
|
||||
render json: { error: 'Only running group stages can be finished' }, status: :unprocessable_entity
|
||||
render json: { error: 'Only running group stages can be finished' }, status: :unprocessable_content
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ class StagesController < ApplicationController
|
|||
render json: @stage
|
||||
synced_tournament = @stage.tournament
|
||||
else
|
||||
render json: @stage.errors, status: :unprocessable_entity
|
||||
render json: @stage.errors, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
|
@ -36,7 +36,7 @@ class StagesController < ApplicationController
|
|||
else
|
||||
render json: {
|
||||
error: 'The state attribute may only be changed to finished'
|
||||
}, status: :unprocessable_entity
|
||||
}, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -46,14 +46,14 @@ class StagesController < ApplicationController
|
|||
unless @stage.over?
|
||||
render json: {
|
||||
error: 'Group Stage still has some matches that are not over yet. Finish them to generate playoffs'
|
||||
}, status: :unprocessable_entity
|
||||
}, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
@stage.groups.each do |group|
|
||||
next if UpdateGroupsGroupScoresAndSave.call(group: group).success?
|
||||
|
||||
render json: { error: 'Updating group scores failed' }, status: :unprocessable_entity
|
||||
render json: { error: 'Updating group scores failed' }, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
|
|
@ -62,14 +62,14 @@ class StagesController < ApplicationController
|
|||
render json: {
|
||||
error: 'Playoffs cannot be generated yet because a decider match is required for an advancing place',
|
||||
blocking_ties: blocking_ties
|
||||
}, status: :unprocessable_entity
|
||||
}, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
return if AddPlayoffsToTournamentAndSave.call(tournament: @stage.tournament,
|
||||
teams: GroupStageService.get_advancing_teams(@stage)).success?
|
||||
|
||||
render json: { error: 'Generating group stage failed' }, status: :unprocessable_entity
|
||||
render json: { error: 'Generating group stage failed' }, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class TeamActionItemsController < ApplicationController
|
|||
)
|
||||
render json: @team_action_item
|
||||
else
|
||||
render json: @team_action_item.errors, status: :unprocessable_entity
|
||||
render json: @team_action_item.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ class TeamActionListsController < ApplicationController
|
|||
|
||||
render json: team_action_list, status: :created
|
||||
rescue TeamActionListService::InvalidSourceError, TeamActionListService::EmptySourceError => e
|
||||
render json: { error: e.message }, status: :unprocessable_entity
|
||||
render json: { error: e.message }, status: :unprocessable_content
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render json: e.record.errors, status: :unprocessable_entity
|
||||
render json: e.record.errors, status: :unprocessable_content
|
||||
end
|
||||
|
||||
# PATCH /tournaments/:tournament_id/team_action_lists/:key/teams/:team_id
|
||||
|
|
@ -33,7 +33,7 @@ class TeamActionListsController < ApplicationController
|
|||
)
|
||||
render json: @team_action_item
|
||||
else
|
||||
render json: @team_action_item.errors, status: :unprocessable_entity
|
||||
render json: @team_action_item.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TeamsController < ApplicationController
|
|||
push_sync_if_needed!(@team.tournament)
|
||||
render json: @team
|
||||
else
|
||||
render json: @team.errors, status: :unprocessable_entity
|
||||
render json: @team.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class TournamentsController < ApplicationController
|
|||
if tournament.save
|
||||
render json: tournament, status: :created, location: tournament
|
||||
else
|
||||
render json: tournament.errors, status: :unprocessable_entity
|
||||
render json: tournament.errors, status: :unprocessable_content
|
||||
end
|
||||
return
|
||||
end
|
||||
|
|
@ -90,14 +90,14 @@ class TournamentsController < ApplicationController
|
|||
end
|
||||
# validate tournament
|
||||
unless tournament.valid?
|
||||
render json: tournament.errors, status: :unprocessable_entity
|
||||
render json: tournament.errors, status: :unprocessable_content
|
||||
return
|
||||
end
|
||||
# return appropriate result
|
||||
if result.success?
|
||||
render json: result.tournament, status: :created, location: result.tournament
|
||||
else
|
||||
render json: { error: 'Tournament generation failed' }, status: :unprocessable_entity
|
||||
render json: { error: 'Tournament generation failed' }, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ class TournamentsController < ApplicationController
|
|||
synced_tournament = @tournament
|
||||
render json: @tournament
|
||||
else
|
||||
render json: @tournament.errors, status: :unprocessable_entity
|
||||
render json: @tournament.errors, status: :unprocessable_content
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
|
@ -139,7 +139,7 @@ class TournamentsController < ApplicationController
|
|||
push_sync_if_needed!(@tournament)
|
||||
render json: @tournament
|
||||
else
|
||||
render json: @tournament.errors, status: :unprocessable_entity
|
||||
render json: @tournament.errors, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -148,14 +148,14 @@ class TournamentsController < ApplicationController
|
|||
TournamentLiveBroadcast.call(@tournament.id)
|
||||
render json: @tournament, include: '**'
|
||||
rescue KeyError, ArgumentError => e
|
||||
render json: { error: e.message }, status: :unprocessable_entity
|
||||
render json: { error: e.message }, status: :unprocessable_content
|
||||
end
|
||||
|
||||
def test_sync
|
||||
unless @tournament.sync_push_enabled?
|
||||
return render json: {
|
||||
error: 'Tournament sync test requires writable tournament with sync_target_url and sync_auth_token'
|
||||
}, status: :unprocessable_entity
|
||||
}, status: :unprocessable_content
|
||||
end
|
||||
|
||||
TournamentSyncPusher.push!(@tournament)
|
||||
|
|
@ -276,7 +276,7 @@ class TournamentsController < ApplicationController
|
|||
teams = params['teams']
|
||||
return if teams.is_a?(Array) && teams.reject { |t| t.is_a? ActionController::Parameters }.count.zero?
|
||||
|
||||
render json: { error: 'Invalid teams array' }, status: :unprocessable_entity
|
||||
render json: { error: 'Invalid teams array' }, status: :unprocessable_content
|
||||
end
|
||||
|
||||
def only_playoff_teams_amount_changed
|
||||
|
|
@ -307,14 +307,14 @@ class TournamentsController < ApplicationController
|
|||
|
||||
render json: {
|
||||
error: 'playoff_teams_amount, instant_finalists_amount and intermediate_round_participants_amount don\'t match'
|
||||
}, status: :unprocessable_entity
|
||||
}, status: :unprocessable_content
|
||||
end
|
||||
def sync_state_params
|
||||
params.require(:snapshot).permit!.to_h
|
||||
end
|
||||
|
||||
def authorize_sync_request!
|
||||
return render json: { error: 'Tournament is not configured to accept sync pushes' }, status: :unprocessable_entity unless @tournament.sync_accepts_push?
|
||||
return render json: { error: 'Tournament is not configured to accept sync pushes' }, status: :unprocessable_content unless @tournament.sync_accepts_push?
|
||||
|
||||
token = request.authorization.to_s.delete_prefix('Bearer ').presence || request.headers['X-Tournament-Sync-Token'].to_s
|
||||
return render json: { error: 'Missing sync token' }, status: :unauthorized if token.blank?
|
||||
|
|
@ -448,12 +448,12 @@ class TournamentsController < ApplicationController
|
|||
return 'timer_reason_text is required for custom timer_reason'
|
||||
end
|
||||
|
||||
if timer_reason != 'custom' && timer_reason_text.present?
|
||||
'timer_reason_text is only allowed when timer_reason is custom'
|
||||
end
|
||||
return unless timer_reason != 'custom' && timer_reason_text.present?
|
||||
|
||||
'timer_reason_text is only allowed when timer_reason is custom'
|
||||
end
|
||||
|
||||
def render_timer_validation_error(message)
|
||||
render json: { error: message }, status: :unprocessable_entity
|
||||
render json: { error: message }, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Devise 4.9 still passes route option hashes to Rails' `resource` helper
|
||||
# positionally. Rails 8.1 accepts that with deprecation warnings and Rails 8.2
|
||||
# removes it, so keep the same Devise routes but pass those options as keywords.
|
||||
module DeviseRoutesRails8Compat
|
||||
def devise_session(mapping, controllers)
|
||||
resource :session, only: [], controller: controllers[:sessions], path: '' do
|
||||
get :new, path: mapping.path_names[:sign_in], as: 'new'
|
||||
post :create, path: mapping.path_names[:sign_in]
|
||||
match :destroy, path: mapping.path_names[:sign_out], as: 'destroy', via: mapping.sign_out_via
|
||||
end
|
||||
end
|
||||
|
||||
def devise_password(mapping, controllers)
|
||||
resource :password,
|
||||
only: [:new, :create, :edit, :update],
|
||||
path: mapping.path_names[:password],
|
||||
controller: controllers[:passwords]
|
||||
end
|
||||
|
||||
def devise_confirmation(mapping, controllers)
|
||||
resource :confirmation,
|
||||
only: [:new, :create, :show],
|
||||
path: mapping.path_names[:confirmation],
|
||||
controller: controllers[:confirmations]
|
||||
end
|
||||
|
||||
def devise_unlock(mapping, controllers)
|
||||
return unless mapping.to.unlock_strategy_enabled?(:email)
|
||||
|
||||
resource :unlock,
|
||||
only: [:new, :create, :show],
|
||||
path: mapping.path_names[:unlock],
|
||||
controller: controllers[:unlocks]
|
||||
end
|
||||
|
||||
def devise_registration(mapping, controllers)
|
||||
resource :registration,
|
||||
only: [:new, :create, :edit, :update, :destroy],
|
||||
path: mapping.path_names[:registration],
|
||||
path_names: {
|
||||
new: mapping.path_names[:sign_up],
|
||||
edit: mapping.path_names[:edit],
|
||||
cancel: mapping.path_names[:cancel]
|
||||
},
|
||||
controller: controllers[:registrations] do
|
||||
get :cancel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActionDispatch::Routing::Mapper.prepend(DeviseRoutesRails8Compat)
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddTimerReasonToTournaments < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :tournaments, :timer_reason, :string
|
||||
|
|
|
|||
|
|
@ -95,14 +95,14 @@ RSpec.describe BeamersController, type: :controller do
|
|||
post :create, params: {
|
||||
tournament_id: @tournament.to_param, name: 'bad', display_state: 'invalid'
|
||||
}
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'rejects duplicate name in same tournament' do
|
||||
post :create, params: {
|
||||
tournament_id: @tournament.to_param, name: @beamer.name, display_state: 'during_game'
|
||||
}
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ RSpec.describe BeamersController, type: :controller do
|
|||
tournament_id: @tournament.to_param, id: @beamer.to_param,
|
||||
display_state: 'bogus'
|
||||
}
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ RSpec.describe MatchScoresController, type: :controller do
|
|||
|
||||
it 'returns unprocessable entity' do
|
||||
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ RSpec.describe MatchesController, type: :controller do
|
|||
|
||||
it 'rejects the request' do
|
||||
post :create, params: { group_id: group.to_param, team_ids: [group.teams.first.id] }
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -167,7 +167,7 @@ RSpec.describe MatchesController, type: :controller do
|
|||
|
||||
patch :swap, params: { id: first_match.to_param, other_match_id: foreign_match.to_param }
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq('Matches must be different group matches from the same group')
|
||||
end
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ RSpec.describe MatchesController, type: :controller do
|
|||
end
|
||||
|
||||
it 'returns an unprocessable entity response' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'doesn\'t change the matches status' do
|
||||
|
|
@ -321,7 +321,7 @@ RSpec.describe MatchesController, type: :controller do
|
|||
|
||||
it 'returns unprocessable entity' do
|
||||
put :update, params: { id: @running_playoff_match.to_param }.merge(finished)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ RSpec.describe MatchesController, type: :controller do
|
|||
allow_any_instance_of(Match).to receive(:winner).and_return(@running_playoff_match.match_scores.first.team)
|
||||
|
||||
put :update, params: { id: @running_playoff_match.to_param }.merge(finished)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -375,14 +375,14 @@ RSpec.describe MatchesController, type: :controller do
|
|||
context 'with invalid params' do
|
||||
it 'renders an unprocessable entity response' do
|
||||
put :update, params: { id: @match.to_param }.merge(invalid_update)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with senseless params' do
|
||||
it 'renders an unprocessable entity response' do
|
||||
put :update, params: { id: @match.to_param }.merge(senseless_update)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -416,7 +416,7 @@ RSpec.describe MatchesController, type: :controller do
|
|||
context 'with invalid params' do
|
||||
it 'renders an unprocessable entity response' do
|
||||
put :update, params: { id: @not_ready_playoff_match.to_param }.merge(invalid_update)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ RSpec.describe StagesController, type: :controller do
|
|||
end
|
||||
|
||||
it 'it returns unprocessable entity' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'returns the correct error' do
|
||||
|
|
@ -145,7 +145,7 @@ RSpec.describe StagesController, type: :controller do
|
|||
end
|
||||
|
||||
it 'it returns unprocessable entity' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'returns the correct error' do
|
||||
|
|
@ -164,7 +164,7 @@ RSpec.describe StagesController, type: :controller do
|
|||
end
|
||||
|
||||
it 'it returns unprocessable entity' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'returns the correct error' do
|
||||
|
|
@ -197,7 +197,7 @@ RSpec.describe StagesController, type: :controller do
|
|||
end
|
||||
|
||||
it 'returns unprocessable entity' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'returns a helpful decider error' do
|
||||
|
|
@ -233,7 +233,7 @@ RSpec.describe StagesController, type: :controller do
|
|||
end
|
||||
|
||||
it 'returns unprocessable entity' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'returns a helpful decider error' do
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ RSpec.describe TeamActionListsController, type: :controller do
|
|||
it 'returns unprocessable entity for unsupported source' do
|
||||
post :create, params: create_params.merge(source: 'unknown_source')
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq('Unsupported team action list source: unknown_source')
|
||||
end
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ RSpec.describe TeamActionListsController, type: :controller do
|
|||
|
||||
post :create, params: create_params.merge(tournament_id: empty_tournament.to_param)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq('Source all_tournament_teams does not currently contain any teams')
|
||||
end
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ RSpec.describe TeamActionListsController, type: :controller do
|
|||
|
||||
post :create, params: create_params
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -308,21 +308,21 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
it 'rejects timestamp_seconds for countup mode' do
|
||||
patch :set_timer, params: { id: @tournament.to_param, timer_mode: 'countup', timestamp_seconds: 120 }
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq('timestamp_seconds is only allowed for countdown mode')
|
||||
end
|
||||
|
||||
it 'rejects invalid timer reason values' do
|
||||
patch :set_timer, params: { id: @tournament.to_param, timestamp_seconds: 120, timer_reason: 'ceremony' }
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq('Invalid timer_reason')
|
||||
end
|
||||
|
||||
it 'requires timer_reason_text for custom timer reason' do
|
||||
patch :set_timer, params: { id: @tournament.to_param, timestamp_seconds: 120, timer_reason: 'custom' }
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq('timer_reason_text is required for custom timer_reason')
|
||||
end
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
timer_reason_text: 'Extra info'
|
||||
}
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error]).to eq(
|
||||
'timer_reason_text is only allowed when timer_reason is custom'
|
||||
)
|
||||
|
|
@ -466,7 +466,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
context 'playoff_teams_amount unacceptable' do
|
||||
shared_examples_for 'wrong playoff_teams_amount' do
|
||||
it 'fails' do
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
it 'returns the correct error message' do
|
||||
expect(deserialize_response(response)[:playoff_teams_amount].first)
|
||||
|
|
@ -522,7 +522,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
data = create_group_tournament_data
|
||||
data[:teams].pop
|
||||
post :create, params: data
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -540,7 +540,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
context 'with invalid parameters' do
|
||||
it 'renders an unprocessable entity response' do
|
||||
put :create, params: { teams: [1, 2, 3] }
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -549,7 +549,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
data = create_group_tournament_data
|
||||
data[:teams] = [{ group: 1 }, { group: 1 }, { group: 2 }, { group: 2 }]
|
||||
post :create, params: data
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -637,18 +637,18 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
|
||||
it 'fails when only instant_finalists_amount is changed' do
|
||||
put :update, params: { id: @filled_tournament.to_param }.merge(instant_finalists_amount: 29)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'fails when only intermediate_round_participants_amount is changed' do
|
||||
put :update, params: { id: @filled_tournament.to_param }.merge(intermediate_round_participants_amount: 29)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'fails when parameters don\'t match' do
|
||||
put :update, params: { id: @filled_tournament.to_param }.merge(intermediate_round_participants_amount: 29,
|
||||
instant_finalists_amount: 32)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'succeeds when all three are changed correctly' do
|
||||
|
|
@ -667,7 +667,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
|
||||
it 'returns unprocessable entity' do
|
||||
put :update, params: { id: @filled_tournament.to_param }.merge(playoff_teams_amount: 8)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
|
||||
it 'doesn\'t change playoff_teams_amount' do
|
||||
|
|
@ -720,7 +720,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
|
||||
it 'fails when playoff_teams_amount is higher than the amount of teams participating' do
|
||||
put :update, params: { id: @filled_tournament.to_param }.merge(playoff_teams_amount: 783)
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -863,7 +863,7 @@ RSpec.describe TournamentsController, type: :controller do
|
|||
it 'rejects sync test without complete leader configuration' do
|
||||
post :test_sync, params: { id: @tournament.to_param }
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(deserialize_response(response)[:error])
|
||||
.to eq('Tournament sync test requires writable tournament with sync_target_url and sync_auth_token')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -154,9 +154,9 @@ RSpec.describe 'Backend API surface HTTP E2E' do
|
|||
timer_reason: 'ceremony'
|
||||
})
|
||||
timer_custom_without_text = owner_client.patch("/tournaments/#{tournament.fetch(:id)}/timer", body: {
|
||||
timestamp_seconds: 120,
|
||||
timer_reason: 'custom'
|
||||
})
|
||||
timestamp_seconds: 120,
|
||||
timer_reason: 'custom'
|
||||
})
|
||||
timer_invalid_seconds = owner_client.patch("/tournaments/#{tournament.fetch(:id)}/timer", body: {
|
||||
timestamp_seconds: 'nope'
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ FactoryBot.define do
|
|||
sequence(:username) { |n| "user#{n}" }
|
||||
sequence(:email) { |n| "user#{n}@example.com" }
|
||||
password { 'password123' }
|
||||
confirmed_at { Time.current }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ RSpec.describe TournamentSnapshotImporter do
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def create_large_source_tournament!
|
||||
tournament = create(
|
||||
:tournament,
|
||||
|
|
@ -142,6 +143,7 @@ RSpec.describe TournamentSnapshotImporter do
|
|||
)
|
||||
tournament.reload
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def create_group_round_robin!(group:, teams:)
|
||||
pairings = [
|
||||
|
|
@ -190,6 +192,7 @@ RSpec.describe TournamentSnapshotImporter do
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def sync_signature(tournament)
|
||||
{
|
||||
name: tournament.name,
|
||||
|
|
@ -244,6 +247,7 @@ RSpec.describe TournamentSnapshotImporter do
|
|||
end
|
||||
}
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def match_signature(match)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue