Allow follower takeover updates
This commit is contained in:
parent
0ba86c84f0
commit
3cbeff617a
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue