From d045df3da882fa8bcd0424df096cec0c61b1eaff Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 23 Oct 2018 20:48:02 +0800 Subject: Allow CE do nothing if route doesn't exist --- doc/development/ee_features.md | 9 +++++---- lib/gitlab/patch/draw_route.rb | 4 ++-- spec/fast_spec_helper.rb | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/development/ee_features.md b/doc/development/ee_features.md index bad9909ed43..b6f053ff0e9 100644 --- a/doc/development/ee_features.md +++ b/doc/development/ee_features.md @@ -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/` diff --git a/lib/gitlab/patch/draw_route.rb b/lib/gitlab/patch/draw_route.rb index c7a0b49a948..1192274cafa 100644 --- a/lib/gitlab/patch/draw_route.rb +++ b/lib/gitlab/patch/draw_route.rb @@ -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) diff --git a/spec/fast_spec_helper.rb b/spec/fast_spec_helper.rb index 134eb25e4b1..fe475e1f7a0 100644 --- a/spec/fast_spec_helper.rb +++ b/spec/fast_spec_helper.rb @@ -8,3 +8,4 @@ require_relative 'support/rspec' require 'active_support/all' ActiveSupport::Dependencies.autoload_paths << 'lib' +ActiveSupport::Dependencies.autoload_paths << 'ee/lib' -- cgit v1.2.1