diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/patch/draw_route.rb | 20 |
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 |