Allow follower takeover updates

This commit is contained in:
Daniel Schädler 2026-04-14 20:11:42 +02:00
parent 0ba86c84f0
commit 3cbeff617a
2 changed files with 17 additions and 1 deletions

View File

@ -248,7 +248,7 @@ class TournamentsController < ApplicationController
end end
def sync_config_only_update? def sync_config_only_update?
allowed = %w[id controller action read_only_mode sync_target_url sync_auth_token] allowed = %w[id controller action format tournament read_only_mode sync_target_url sync_auth_token]
(params.keys - allowed).empty? (params.keys - allowed).empty?
end end

View File

@ -397,6 +397,22 @@ RSpec.describe TournamentsController, type: :controller do
expect(@tournament.sync_auth_token).to eq('new-token') expect(@tournament.sync_auth_token).to eq('new-token')
end end
it 'allows follower takeover when only read_only_mode is disabled' do
@tournament.update!(read_only_mode: true, sync_auth_token: 'old-token')
request.headers['CONTENT_TYPE'] = 'application/json'
put :update, params: {
id: @tournament.to_param,
read_only_mode: false
}, as: :json
expect(response).to have_http_status(:ok)
@tournament.reload
expect(@tournament.read_only_mode?).to eq(false)
expect(@tournament.sync_target_url).to be_blank
expect(@tournament.sync_auth_token).to be_blank
end
it 'blocks normal updates while tournament is read only' do it 'blocks normal updates while tournament is read only' do
@tournament.update!(read_only_mode: true, sync_auth_token: 'shared-secret') @tournament.update!(read_only_mode: true, sync_auth_token: 'shared-secret')