Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2019-02-20 19:56:19 +0300
committerBrett Walker <bwalker@gitlab.com>2019-06-19 20:29:10 +0300
commit6b4f93c0349e9d54cb48f1d5cf025c5e5ce77aee (patch)
tree422fdbc63f17d7836fe2cff92586b59a5febd3d0 /spec/controllers/admin
parente999e1de7baadc34e7fccf76e76991a7adf31b0e (diff)
Update application settings using correct action
Updating multiple application settings panels through a single action causes the incorrect action to be shown when there are errors. Instead, make each panel action handle both updating and display.
Diffstat (limited to 'spec/controllers/admin')
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb
index b89348b7a7e..c7f814c58c0 100644
--- a/spec/controllers/admin/application_settings_controller_spec.rb
+++ b/spec/controllers/admin/application_settings_controller_spec.rb
@@ -116,6 +116,34 @@ describe Admin::ApplicationSettingsController do
end
end
end
+
+ describe 'verify panel actions' do
+ shared_examples 'renders correct panels' do
+ it 'renders correct action on error' do
+ allow_any_instance_of(ApplicationSettings::UpdateService).to receive(:execute).and_return(false)
+
+ patch action, params: { application_setting: { unused_param: true } }
+
+ expect(subject).to render_template(action)
+ end
+
+ it 'redirects to same panel on success' do
+ allow_any_instance_of(ApplicationSettings::UpdateService).to receive(:execute).and_return(true)
+ 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
+ let(:action) { valid_action }
+ end
+ end
+ end
end
describe 'PUT #reset_registration_token' do