summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2019-05-10 20:49:16 +0700
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2019-05-15 11:54:30 +0700
commit224c01033fa8eafe53dd1b1d2dfdd90605a000bb (patch)
treeaab9e6f86569c56a0ade22880dbf3efd72b1cea2
parent0f6500d5a770a11e7096208584ad4448eecc355e (diff)
downloadgitlab-ce-224c01033fa8eafe53dd1b1d2dfdd90605a000bb.tar.gz
Refactor RoutableActions to allow for additional checks
-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