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
path: root/spec
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
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')
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb28
-rw-r--r--spec/features/admin/admin_settings_spec.rb21
2 files changed, 49 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
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index 93ccb03d822..45ef5d07ff0 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -379,6 +379,27 @@ describe 'Admin updates settings' do
expect(page).to have_content "Application settings saved successfully"
end
+ it 'Change Real-time features settings' do
+ page.within('.as-realtime') do
+ fill_in 'Polling interval multiplier', with: 5.0
+ click_button 'Save changes'
+ end
+
+ expect(Gitlab::CurrentSettings.polling_interval_multiplier).to eq 5.0
+ expect(page).to have_content "Application settings saved successfully"
+ end
+
+ it 'shows an error when validation fails' do
+ page.within('.as-realtime') do
+ fill_in 'Polling interval multiplier', with: -1.0
+ click_button 'Save changes'
+ end
+
+ expect(Gitlab::CurrentSettings.polling_interval_multiplier).not_to eq(-1.0)
+ expect(page)
+ .to have_content "The form contains the following error: Polling interval multiplier must be greater than or equal to 0"
+ end
+
context 'When pages_auto_ssl is enabled' do
before do
stub_feature_flags(pages_auto_ssl: true)