From 3cbeff617aaec24d4276fb29895e044f0c7fe031 Mon Sep 17 00:00:00 2001 From: Malaber Date: Tue, 14 Apr 2026 20:11:42 +0200 Subject: [PATCH] Allow follower takeover updates --- app/controllers/tournaments_controller.rb | 2 +- spec/controllers/tournaments_controller_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index d2d7da3..5576941 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -248,7 +248,7 @@ class TournamentsController < ApplicationController end 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? end diff --git a/spec/controllers/tournaments_controller_spec.rb b/spec/controllers/tournaments_controller_spec.rb index f3080e0..a0447e4 100644 --- a/spec/controllers/tournaments_controller_spec.rb +++ b/spec/controllers/tournaments_controller_spec.rb @@ -397,6 +397,22 @@ RSpec.describe TournamentsController, type: :controller do expect(@tournament.sync_auth_token).to eq('new-token') 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 @tournament.update!(read_only_mode: true, sync_auth_token: 'shared-secret')