Commit a053ae57 authored by Brett Walker's avatar Brett Walker Committed by Douglas Barbosa Alexandre

Refactor geo and template application settings

routes into EE
parent 9b4313cf
......@@ -6,9 +6,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :set_application_setting
before_action :whitelist_query_limiting, only: [:usage_data]
VALID_SETTING_PANELS = %w(general integrations repository templates
VALID_SETTING_PANELS = %w(general integrations repository
ci_cd reporting metrics_and_profiling
network geo preferences).freeze
network preferences).freeze
VALID_SETTING_PANELS.each do |action|
define_method(action) { perform_update if submitted? }
......@@ -145,10 +145,15 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
def render_update_error
action = VALID_SETTING_PANELS.include?(action_name) ? action_name : :general
action = valid_setting_panels.include?(action_name) ? action_name : :general
render action
end
# overridden in EE
def valid_setting_panels
VALID_SETTING_PANELS
end
end
Admin::ApplicationSettingsController.prepend_if_ee('EE::Admin::ApplicationSettingsController')
......@@ -114,7 +114,7 @@ namespace :admin do
put :reset_registration_token
put :reset_health_check_token
put :clear_repository_check_states
match :general, :integrations, :repository, :templates, :ci_cd, :reporting, :metrics_and_profiling, :network, :geo, :preferences, via: [:get, :patch]
match :general, :integrations, :repository, :ci_cd, :reporting, :metrics_and_profiling, :network, :preferences, via: [:get, :patch]
get :lets_encrypt_terms_of_service
end
......
......@@ -3,6 +3,14 @@
module EE
module Admin
module ApplicationSettingsController
extend ::Gitlab::Utils::Override
EE_VALID_SETTING_PANELS = %w(geo templates).freeze
EE_VALID_SETTING_PANELS.each do |action|
define_method(action) { perform_update if submitted? }
end
def visible_application_setting_attributes
attrs = super
......@@ -36,6 +44,13 @@ module EE
attrs
end
private
override :valid_setting_panels
def valid_setting_panels
super + EE_VALID_SETTING_PANELS
end
end
end
end
......@@ -25,6 +25,11 @@ namespace :admin do
get :download, on: :member
end
# using `only: []` to keep duplicate routes from being created
resource :application_settings, only: [] do
match :geo, :templates, via: [:get, :patch]
end
namespace :geo do
get '/' => 'nodes#index'
......
......@@ -134,7 +134,7 @@ describe Admin::ApplicationSettingsController do
end
describe 'verify panel actions' do
%w[templates geo].each do |valid_action|
Admin::ApplicationSettingsController::EE_VALID_SETTING_PANELS.each do |valid_action|
it_behaves_like 'renders correct panels' do
let(:action) { valid_action }
end
......
......@@ -59,4 +59,16 @@ describe 'EE-specific admin routing' do
expect(post('/admin/email')).to route_to('admin/emails#create')
end
end
describe Admin::ApplicationSettingsController, 'routing' do
it 'routes to #geo' do
expect(get('/admin/application_settings/geo')).to route_to('admin/application_settings#geo')
expect(patch('/admin/application_settings/geo')).to route_to('admin/application_settings#geo')
end
it 'routes to #templates' do
expect(get('/admin/application_settings/templates')).to route_to('admin/application_settings#templates')
expect(patch('/admin/application_settings/templates')).to route_to('admin/application_settings#templates')
end
end
end
......@@ -118,7 +118,7 @@ describe Admin::ApplicationSettingsController do
end
describe 'verify panel actions' do
(Admin::ApplicationSettingsController::VALID_SETTING_PANELS - %w(templates geo)).each do |valid_action|
Admin::ApplicationSettingsController::VALID_SETTING_PANELS.each do |valid_action|
it_behaves_like 'renders correct panels' do
let(:action) { valid_action }
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment