diff --git a/app/controllers/settings/preferences/appearance_controller.rb b/app/controllers/settings/preferences/appearance_controller.rb index 80ea57bd2d2..4d7d12bb7f7 100644 --- a/app/controllers/settings/preferences/appearance_controller.rb +++ b/app/controllers/settings/preferences/appearance_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Settings::Preferences::AppearanceController < Settings::PreferencesController +class Settings::Preferences::AppearanceController < Settings::Preferences::BaseController private def after_update_redirect_path diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences/base_controller.rb similarity index 81% rename from app/controllers/settings/preferences_controller.rb rename to app/controllers/settings/preferences/base_controller.rb index 281deb64d17..faf778a7e52 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences/base_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Settings::PreferencesController < Settings::BaseController +class Settings::Preferences::BaseController < Settings::BaseController def show; end def update @@ -15,7 +15,7 @@ class Settings::PreferencesController < Settings::BaseController private def after_update_redirect_path - settings_preferences_path + raise 'Override in controller' end def user_params diff --git a/app/controllers/settings/preferences/notifications_controller.rb b/app/controllers/settings/preferences/notifications_controller.rb index a16ae6a672a..66d6c9a2f7b 100644 --- a/app/controllers/settings/preferences/notifications_controller.rb +++ b/app/controllers/settings/preferences/notifications_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Settings::Preferences::NotificationsController < Settings::PreferencesController +class Settings::Preferences::NotificationsController < Settings::Preferences::BaseController private def after_update_redirect_path diff --git a/app/controllers/settings/preferences/other_controller.rb b/app/controllers/settings/preferences/other_controller.rb index 07eb89a7623..a19fbf5c48c 100644 --- a/app/controllers/settings/preferences/other_controller.rb +++ b/app/controllers/settings/preferences/other_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Settings::Preferences::OtherController < Settings::PreferencesController +class Settings::Preferences::OtherController < Settings::Preferences::BaseController private def after_update_redirect_path diff --git a/spec/controllers/settings/preferences/appearance_controller_spec.rb b/spec/controllers/settings/preferences/appearance_controller_spec.rb index 083bf495449..9a98a418865 100644 --- a/spec/controllers/settings/preferences/appearance_controller_spec.rb +++ b/spec/controllers/settings/preferences/appearance_controller_spec.rb @@ -31,5 +31,11 @@ describe Settings::Preferences::AppearanceController do expect(response).to redirect_to(settings_preferences_appearance_path) end + + it 'renders show on failure' do + put :update, params: { user: { locale: 'fake option' } } + + expect(response).to render_template('preferences/appearance/show') + end end end diff --git a/spec/controllers/settings/preferences/base_controller_spec.rb b/spec/controllers/settings/preferences/base_controller_spec.rb new file mode 100644 index 00000000000..53b3a461ed5 --- /dev/null +++ b/spec/controllers/settings/preferences/base_controller_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Settings::Preferences::BaseController do + describe 'after_update_redirect_path' do + it 'raises error when called' do + expect { described_class.new.send(:after_update_redirect_path) }.to raise_error(/Override/) + end + end +end