Allow CE do nothing if route doesn't exist

This commit is contained in:
Lin Jen-Shin 2018-10-23 20:48:02 +08:00
parent 52fa309e86
commit d045df3da8
3 changed files with 8 additions and 6 deletions

View file

@ -338,13 +338,14 @@ When we add `draw :admin` in `config/routes.rb`, the application will try to
load the file located in `config/routes/admin.rb`, and also try to load the
file located in `ee/config/routes/admin.rb`.
It should at least load one file, at most two files. If it cannot find any
files, an error will be raised.
In EE, it should at least load one file, at most two files. If it cannot find
any files, an error will be raised. In CE, since we don't know if there will
be an EE route, it will not raise any errors even if it cannot find anything.
This means if we want to extend a particular CE route file, just add the same
file located in `ee/config/routes`. If we want to add an EE only route, we
could still use `draw :ee_only` and add `ee/config/routes/ee_only.rb` without
adding `config/routes/ee_only.rb`.
could still put `draw :ee_only` in both CE and EE, and add
`ee/config/routes/ee_only.rb` in EE, similar to `render_if_exists`.
### Code in `app/controllers/`

View file

@ -16,8 +16,8 @@ module Gitlab
draw_route(route_path("config/routes/#{routes_name}.rb"))
end
def draw_ee(routes_name)
draw_route(route_path("ee/config/routes/#{routes_name}.rb"))
def draw_ee(_)
true
end
def route_path(routes_name)

View file

@ -8,3 +8,4 @@ require_relative 'support/rspec'
require 'active_support/all'
ActiveSupport::Dependencies.autoload_paths << 'lib'
ActiveSupport::Dependencies.autoload_paths << 'ee/lib'