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
path: root/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-10-17 16:29:39 +0300
committerLin Jen-Shin <godfat@godfat.org>2018-10-26 09:27:05 +0300
commitf1701c0fec096184a5908df65187573209dd6254 (patch)
treea0e868088b9a8b70fbe25fcb4ed799c2c350f799 /lib
parent1581f75fb511fed171e8105c1a0811561a2f2dcc (diff)
Make it possible to add EE only route
And if it cannot find any routes, raise an error
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/patch/draw_route.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/gitlab/patch/draw_route.rb b/lib/gitlab/patch/draw_route.rb
index 4396e811a8c..f8ae6f7afc0 100644
--- a/lib/gitlab/patch/draw_route.rb
+++ b/lib/gitlab/patch/draw_route.rb
@@ -5,16 +5,28 @@
module Gitlab
module Patch
module DrawRoute
+ RoutesNotFound = Class.new(StandardError)
+
def draw(routes_name)
- instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
+ draw_ce(routes_name) | draw_ee(routes_name) ||
+ raise(RoutesNotFound.new("Cannot find #{routes_name}"))
+ end
- draw_ee(routes_name)
+ def draw_ce(routes_name)
+ draw_route(Rails.root.join("config/routes/#{routes_name}.rb"))
end
def draw_ee(routes_name)
- path = Rails.root.join("ee/config/routes/#{routes_name}.rb")
+ draw_route(Rails.root.join("ee/config/routes/#{routes_name}.rb"))
+ end
- instance_eval(File.read(path)) if File.exist?(path)
+ def draw_route(path)
+ if File.exist?(path)
+ instance_eval(File.read(path))
+ true
+ else
+ false
+ end
end
end
end