diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-08 09:53:35 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-08 09:53:35 -0800 |
commit | 57a65ede77b7bbae6e3b2a7aa52135de7b0c2f8e (patch) | |
tree | 3f1d72a04c3deefb8a911d013e686b036541af60 /app/controllers | |
parent | 8589b4e137f50293952923bb07e2814257d7784d (diff) | |
download | gitlab-ce-57a65ede77b7bbae6e3b2a7aa52135de7b0c2f8e.tar.gz |
Improve application settings and write tests
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/registrations_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/sessions_controller.rb | 22 |
4 files changed, 22 insertions, 20 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index d6e950b0007..39ca0b4feba 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -4,13 +4,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController def show end - def edit - end - def update - @application_setting.update_attributes(application_setting_params) - - redirect_to admin_application_settings_path + if @application_setting.update_attributes(application_setting_params) + redirect_to admin_application_settings_path, + notice: 'Application settings saved successfully' + else + render :show + end end private diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b8cae469e3..b83de68c5d2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ require 'gon' class ApplicationController < ActionController::Base + include Gitlab::CurrentSettings + before_filter :authenticate_user_from_token! before_filter :authenticate_user! before_filter :reject_blocked! @@ -13,7 +15,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - helper_method :abilities, :can? + helper_method :abilities, :can?, :current_application_settings rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 7c15eab4345..981dc2d8023 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -26,8 +26,8 @@ class RegistrationsController < Devise::RegistrationsController private def signup_enabled? - unless ApplicationSetting.current.signup_enabled - redirect_to new_user_session_path + if current_application_settings.signup_enabled? + redirect_to(new_user_session_path) end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 5ced98152a5..7b6982c5074 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,16 +1,16 @@ class SessionsController < Devise::SessionsController - def new - redirect_path = if request.referer.present? && (params['redirect_to_referer'] == 'yes') - referer_uri = URI(request.referer) - if referer_uri.host == Gitlab.config.gitlab.host - referer_uri.path - else - request.fullpath - end - else - request.fullpath - end + redirect_path = + if request.referer.present? && (params['redirect_to_referer'] == 'yes') + referer_uri = URI(request.referer) + if referer_uri.host == Gitlab.config.gitlab.host + referer_uri.path + else + request.fullpath + end + else + request.fullpath + end # Prevent a 'you are already signed in' message directly after signing: # we should never redirect to '/users/sign_in' after signing in successfully. |