Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2019-05-10 16:49:16 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2019-05-15 07:54:30 +0300
commit224c01033fa8eafe53dd1b1d2dfdd90605a000bb (patch)
treeaab9e6f86569c56a0ade22880dbf3efd72b1cea2 /app/controllers
parent0f6500d5a770a11e7096208584ad4448eecc355e (diff)
Refactor RoutableActions to allow for additional checks
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/concerns/routable_actions.rb12
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