diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-05-04 17:06:01 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-05-05 12:12:50 -0700 |
commit | f05469f99b8c52c4dab7ac9160b47676c87124f9 (patch) | |
tree | 89d39b3c7672d89fd05346c2ea930ae039a95c4a /app/controllers/concerns/routable_actions.rb | |
parent | 9e48f02ea802814e4df1f1de5ed509942dca7581 (diff) | |
download | gitlab-ce-f05469f99b8c52c4dab7ac9160b47676c87124f9.tar.gz |
Resolve discussions
Diffstat (limited to 'app/controllers/concerns/routable_actions.rb')
-rw-r--r-- | app/controllers/concerns/routable_actions.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb index ba236fa5459..d4ab6782444 100644 --- a/app/controllers/concerns/routable_actions.rb +++ b/app/controllers/concerns/routable_actions.rb @@ -1,10 +1,10 @@ module RoutableActions extend ActiveSupport::Concern - def find_routable!(routable_klass, requested_full_path, extra_authorization_method: nil) + def find_routable!(routable_klass, requested_full_path, extra_authorization_proc: nil) routable = routable_klass.find_by_full_path(requested_full_path, follow_redirects: request.get?) - if authorized?(routable_klass, routable, extra_authorization_method) + if routable_authorized?(routable_klass, routable, extra_authorization_proc) ensure_canonical_path(routable, requested_full_path) routable else @@ -13,12 +13,12 @@ module RoutableActions end end - def authorized?(routable_klass, routable, extra_authorization_method) + def routable_authorized?(routable_klass, routable, extra_authorization_proc) action = :"read_#{routable_klass.to_s.underscore}" return false unless can?(current_user, action, routable) - if extra_authorization_method - send(extra_authorization_method, routable) + if extra_authorization_proc + extra_authorization_proc.call(routable) else true end @@ -27,9 +27,11 @@ module RoutableActions def ensure_canonical_path(routable, requested_path) return unless request.get? - canonical_path = routable.try(:full_path) || routable.namespace.full_path + canonical_path = routable.full_path if canonical_path != requested_path - flash[:notice] = 'This project has moved to this location. Please update your links and bookmarks.' + if canonical_path.casecmp(requested_path) != 0 + flash[:notice] = "Project '#{requested_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path." + end redirect_to request.original_url.sub(requested_path, canonical_path) end end |