diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-01-21 12:54:10 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-01-21 12:54:10 -0500 |
commit | 0f79620ccb049dc8146ab3c639f993122329eb83 (patch) | |
tree | 34c3e63a5624c1aaee605be20fc410bba16422fb /app/controllers/application_controller.rb | |
parent | 4d345bc4003022ca22b5e7f42069c5a6bde41b6c (diff) | |
download | gitlab-ce-0f79620ccb049dc8146ab3c639f993122329eb83.tar.gz |
Little refactor plus some specs.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4c4e2ac3d3c..9df37a677c0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -410,18 +410,12 @@ class ApplicationController < ActionController::Base def set_default_sort controller_name = params[:controller].sub(/Controller\Z/, '').underscore - cookie_suffix = "_sort_#{controller_name}" - - key = if @project - "#{@project.cookie_key}#{cookie_suffix}" - elsif @group - "#{@group.cookie_key}#{cookie_suffix}" - else - "#{current_user.cookie_key}#{cookie_suffix}" - end - - cookies[key] ||= 'id_desc' - cookies[key] = params[:sort] if params[:sort].present? + cookie_suffix = "_sort_#{controller_name}" + + key = "#{(@project || @group || current_user).cookie_key}#{cookie_suffix}" + + cookies[key] ||= 'id_desc' + cookies[key] = params[:sort] if params[:sort].present? params[:sort] = cookies[key] end end |