diff options
Diffstat (limited to 'spec/controllers/admin')
-rw-r--r-- | spec/controllers/admin/application_settings_controller_spec.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index d62e0a97609..4eb0545eb6c 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -118,7 +118,32 @@ describe Admin::ApplicationSettingsController do end describe 'verify panel actions' do - (Admin::ApplicationSettingsController::VALID_SETTING_PANELS - %w(templates geo)).each do |valid_action| + 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 + + (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 |