diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2019-05-10 20:49:16 +0700 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2019-05-15 11:54:30 +0700 |
commit | 224c01033fa8eafe53dd1b1d2dfdd90605a000bb (patch) | |
tree | aab9e6f86569c56a0ade22880dbf3efd72b1cea2 /app | |
parent | 0f6500d5a770a11e7096208584ad4448eecc355e (diff) | |
download | gitlab-ce-224c01033fa8eafe53dd1b1d2dfdd90605a000bb.tar.gz |
Refactor RoutableActions to allow for additional checks
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/routable_actions.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb index 5624eb3aa45..236f095ae31 100644 --- a/app/controllers/concerns/routable_actions.rb +++ b/app/controllers/concerns/routable_actions.rb @@ -9,9 +9,7 @@ module RoutableActions ensure_canonical_path(routable, requested_full_path) routable else - if not_found_or_authorized_proc - not_found_or_authorized_proc.call(routable) - end + perform_not_found_actions(routable, [not_found_or_authorized_proc]) route_not_found unless performed? @@ -19,6 +17,14 @@ module RoutableActions end end + def perform_not_found_actions(routable, actions) + actions.compact.each do |action| + break if performed? + + action.call(routable) + end + end + def routable_authorized?(routable, extra_authorization_proc) return false unless routable |