Commit 7f030e22 authored by Brett Walker's avatar Brett Walker

Refactored settings 'show' panel to 'general'

This keeps the routes consistent - each panel has it's own
specific route.  In addition, makes the naming more
consistent, using 'General' for the panel name.
parent 0b623c08
...@@ -6,15 +6,16 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -6,15 +6,16 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :set_application_setting before_action :set_application_setting
before_action :whitelist_query_limiting, only: [:usage_data] before_action :whitelist_query_limiting, only: [:usage_data]
VALID_SETTING_PANELS = %w(show integrations repository templates VALID_SETTING_PANELS = %w(general integrations repository templates
ci_cd reporting metrics_and_profiling ci_cd reporting metrics_and_profiling
network geo preferences).freeze network geo preferences).freeze
def show VALID_SETTING_PANELS.each do |action|
define_method(action) { perform_update if submitted? }
end end
(VALID_SETTING_PANELS - %w(show)).each do |action| def show
define_method(action) { perform_update if submitted? } render :general
end end
def update def update
...@@ -144,7 +145,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -144,7 +145,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end end
def render_update_error def render_update_error
action = VALID_SETTING_PANELS.include?(action_name) ? action_name : :show action = VALID_SETTING_PANELS.include?(action_name) ? action_name : :general
render action render action
end end
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-account-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-account-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-merge-request-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-merge-request-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= _('External Classification Policy Authorization') = _('External Classification Policy Authorization')
.settings-content .settings-content
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-external-auth-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-external-auth-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-signin-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-signin-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-signup-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-signup-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-terminal-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-terminal-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-terms-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-terms-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
= form_for @application_setting, url: admin_application_settings_path(anchor: 'js-visibility-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-visibility-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
- breadcrumb_title _("Settings") - breadcrumb_title _("General")
- page_title _("Settings") - page_title _("General")
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
%section.settings.as-visibility-access.no-animate#js-visibility-settings{ class: ('expanded' if expanded_by_default?) } %section.settings.as-visibility-access.no-animate#js-visibility-settings{ class: ('expanded' if expanded_by_default?) }
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
%p %p
= _('Manage Web IDE features') = _('Manage Web IDE features')
.settings-content .settings-content
= form_for @application_setting, url: admin_application_settings_path(anchor: "#js-web-ide-settings"), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: general_admin_application_settings_path(anchor: "#js-web-ide-settings"), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) = form_errors(@application_setting)
%fieldset %fieldset
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
= _('Settings') = _('Settings')
%li.divider.fly-out-top-item %li.divider.fly-out-top-item
= nav_link(path: 'application_settings#show') do = nav_link(path: 'application_settings#show') do
= link_to admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do = link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do
%span %span
= _('General') = _('General')
= nav_link(path: 'application_settings#integrations') do = nav_link(path: 'application_settings#integrations') do
......
...@@ -110,7 +110,7 @@ namespace :admin do ...@@ -110,7 +110,7 @@ namespace :admin do
put :reset_registration_token put :reset_registration_token
put :reset_health_check_token put :reset_health_check_token
put :clear_repository_check_states put :clear_repository_check_states
match :integrations, :repository, :templates, :ci_cd, :reporting, :metrics_and_profiling, :network, :geo, :preferences, via: [:get, :patch] match :general, :integrations, :repository, :templates, :ci_cd, :reporting, :metrics_and_profiling, :network, :geo, :preferences, via: [:get, :patch]
get :lets_encrypt_terms_of_service get :lets_encrypt_terms_of_service
end end
......
...@@ -116,21 +116,21 @@ describe Admin::ApplicationSettingsController do ...@@ -116,21 +116,21 @@ describe Admin::ApplicationSettingsController do
it 'does not accept negative repository_size_limit' do it 'does not accept negative repository_size_limit' do
put :update, params: { application_setting: { repository_size_limit: '-100' } } put :update, params: { application_setting: { repository_size_limit: '-100' } }
expect(response).to render_template(:show) expect(response).to render_template(:general)
expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present
end end
it 'does not accept invalid repository_size_limit' do it 'does not accept invalid repository_size_limit' do
put :update, params: { application_setting: { repository_size_limit: 'one thousand' } } put :update, params: { application_setting: { repository_size_limit: 'one thousand' } }
expect(response).to render_template(:show) expect(response).to render_template(:general)
expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present
end end
it 'does not accept empty repository_size_limit' do it 'does not accept empty repository_size_limit' do
put :update, params: { application_setting: { repository_size_limit: '' } } put :update, params: { application_setting: { repository_size_limit: '' } }
expect(response).to render_template(:show) expect(response).to render_template(:general)
expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present expect(assigns(:application_setting).errors[:repository_size_limit]).to be_present
end end
end end
......
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
class General < Page::Base class General < Page::Base
include QA::Page::Settings::Common include QA::Page::Settings::Common
view 'app/views/admin/application_settings/show.html.haml' do view 'app/views/admin/application_settings/general.html.haml' do
element :account_and_limit_settings element :account_and_limit_settings
end end
......
...@@ -118,32 +118,7 @@ describe Admin::ApplicationSettingsController do ...@@ -118,32 +118,7 @@ describe Admin::ApplicationSettingsController do
end end
describe 'verify panel actions' do describe 'verify panel actions' do
shared_examples 'renders correct panels' do (Admin::ApplicationSettingsController::VALID_SETTING_PANELS - %w(templates geo)).each do |valid_action|
it 'renders correct action on error' do
expect_next_instance_of(ApplicationSettings::UpdateService) do |service|
allow(service).to receive(:execute).and_return(false)
end
patch action, params: { application_setting: { unused_param: true } }
expect(subject).to render_template(action)
end
it 'redirects to same panel on success' do
expect_next_instance_of(ApplicationSettings::UpdateService) do |service|
allow(service).to receive(:execute).and_return(true)
end
referer_path = public_send("#{action}_admin_application_settings_path")
request.env["HTTP_REFERER"] = referer_path
patch action, params: { application_setting: { unused_param: true } }
expect(subject).to redirect_to(referer_path)
end
end
(Admin::ApplicationSettingsController::VALID_SETTING_PANELS - %w(show templates geo)).each do |valid_action|
it_behaves_like 'renders correct panels' do it_behaves_like 'renders correct panels' do
let(:action) { valid_action } let(:action) { valid_action }
end end
......
...@@ -76,6 +76,7 @@ describe 'Admin disables Git access protocol', :js do ...@@ -76,6 +76,7 @@ describe 'Admin disables Git access protocol', :js do
context 'with nothing disabled' do context 'with nothing disabled' do
before do before do
create(:personal_key, user: admin) create(:personal_key, user: admin)
allow_all_protocols
end end
it 'shows default SSH url and protocol selection dropdown' do it 'shows default SSH url and protocol selection dropdown' do
...@@ -107,6 +108,10 @@ describe 'Admin disables Git access protocol', :js do ...@@ -107,6 +108,10 @@ describe 'Admin disables Git access protocol', :js do
visit project_path(project) visit project_path(project)
end end
def allow_all_protocols
switch_git_protocol(1)
end
def disable_http_protocol def disable_http_protocol
switch_git_protocol(2) switch_git_protocol(2)
end end
......
...@@ -15,7 +15,7 @@ describe 'Admin updates settings' do ...@@ -15,7 +15,7 @@ describe 'Admin updates settings' do
context 'General page' do context 'General page' do
before do before do
visit admin_application_settings_path visit general_admin_application_settings_path
end end
it 'Change visibility settings' do it 'Change visibility settings' do
......
...@@ -26,7 +26,7 @@ describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', type: :c ...@@ -26,7 +26,7 @@ describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', type: :c
it 'application_settings/accounts_and_limit.html' do it 'application_settings/accounts_and_limit.html' do
stub_application_setting(user_default_external: false) stub_application_setting(user_default_external: false)
get :show get :general
expect(response).to be_successful expect(response).to be_successful
end end
......
...@@ -210,7 +210,7 @@ if (process.env.BABEL_ENV === 'coverage') { ...@@ -210,7 +210,7 @@ if (process.env.BABEL_ENV === 'coverage') {
'./terminal/terminal_bundle.js', './terminal/terminal_bundle.js',
'./users/users_bundle.js', './users/users_bundle.js',
'./issue_show/index.js', './issue_show/index.js',
'./pages/admin/application_settings/show/index.js', './pages/admin/application_settings/general/index.js',
]; ];
describe('Uncovered files', function() { describe('Uncovered files', function() {
......
# frozen_string_literal: true
shared_examples 'renders correct panels' do
it 'renders correct action on error' do
expect_next_instance_of(ApplicationSettings::UpdateService) do |service|
allow(service).to receive(:execute).and_return(false)
end
patch action, params: { application_setting: { unused_param: true } }
expect(subject).to render_template(action)
end
it 'redirects to same panel on success' do
expect_next_instance_of(ApplicationSettings::UpdateService) do |service|
allow(service).to receive(:execute).and_return(true)
end
referer_path = public_send("#{action}_admin_application_settings_path")
request.env["HTTP_REFERER"] = referer_path
patch action, params: { application_setting: { unused_param: true } }
expect(subject).to redirect_to(referer_path)
end
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