Put EE routes in EE files under EE directories
This commit is contained in:
parent
679c0048a8
commit
1581f75fb5
6 changed files with 43 additions and 13 deletions
|
@ -76,6 +76,7 @@ Naming/FileName:
|
|||
- 'qa/qa/specs/**/*'
|
||||
- 'qa/bin/*'
|
||||
- 'config/**/*'
|
||||
- 'ee/config/**/*'
|
||||
- 'lib/generators/**/*'
|
||||
- 'locale/unfound_translations.rb'
|
||||
- 'ee/locale/unfound_translations.rb'
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
# Adds draw method into Rails routing
|
||||
# It allows us to keep routing splitted into files
|
||||
class ActionDispatch::Routing::Mapper
|
||||
def draw(routes_name)
|
||||
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
|
||||
end
|
||||
end
|
||||
# It allows us to keep routing split into files
|
||||
ActionDispatch::Routing::Mapper.prepend Gitlab::Patch::DrawRoute
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace :admin do
|
|||
resource :logs, only: [:show]
|
||||
resource :health_check, controller: 'health_check', only: [:show]
|
||||
resource :background_jobs, controller: 'background_jobs', only: [:show]
|
||||
|
||||
resource :system_info, controller: 'system_info', only: [:show]
|
||||
resources :requests_profiles, only: [:index, :show], param: :name, constraints: { name: /.+\.html/ }
|
||||
|
||||
|
@ -104,6 +105,7 @@ namespace :admin do
|
|||
|
||||
resource :application_settings, only: [:show, :update] do
|
||||
resources :services, only: [:index, :edit, :update]
|
||||
|
||||
get :usage_data
|
||||
put :reset_registration_token
|
||||
put :reset_health_check_token
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
resources :groups, only: [:index, :new, :create] do
|
||||
post :preview_markdown
|
||||
end
|
||||
|
@ -63,7 +65,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
|
|||
end
|
||||
end
|
||||
|
||||
# On CE only index and show actions are needed
|
||||
resources :boards, only: [:index, :show]
|
||||
|
||||
resources :runners, only: [:index, :edit, :update, :destroy, :show] do
|
||||
|
|
|
@ -171,7 +171,7 @@ There are a few gotchas with it:
|
|||
class Base
|
||||
def execute
|
||||
return unless enabled?
|
||||
|
||||
|
||||
# ...
|
||||
# ...
|
||||
end
|
||||
|
@ -185,12 +185,12 @@ There are a few gotchas with it:
|
|||
class Base
|
||||
def execute
|
||||
return unless enabled?
|
||||
|
||||
|
||||
do_something
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def do_something
|
||||
# ...
|
||||
# ...
|
||||
|
@ -204,14 +204,14 @@ There are a few gotchas with it:
|
|||
```ruby
|
||||
module EE::Base
|
||||
extend ::Gitlab::Utils::Override
|
||||
|
||||
|
||||
override :do_something
|
||||
def do_something
|
||||
# Follow the above pattern to call super and extend it
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
This would require updating CE first, or make sure this is back ported to CE.
|
||||
|
||||
When prepending, place them in the `ee/` specific sub-directory, and
|
||||
|
@ -332,6 +332,15 @@ full implementation details.
|
|||
[ce-mr-full-private]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12373
|
||||
[ee-mr-full-private]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2199
|
||||
|
||||
### Code in `config/routes`
|
||||
|
||||
When we add `draw :admin` in `config/routes.rb`, the application will also
|
||||
load the file located in `config/routes/admin.rb`, and also
|
||||
`ee/config/routes/admin.rb` if the file exists.
|
||||
|
||||
So if we want to extend a particular route file, just add the same file
|
||||
located in `ee/config/routes`.
|
||||
|
||||
### Code in `app/controllers/`
|
||||
|
||||
In controllers, the most common type of conflict is with `before_action` that
|
||||
|
|
21
lib/gitlab/patch/draw_route.rb
Normal file
21
lib/gitlab/patch/draw_route.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# We're patching `ActionDispatch::Routing::Mapper` in
|
||||
# config/initializers/routing_draw.rb
|
||||
module Gitlab
|
||||
module Patch
|
||||
module DrawRoute
|
||||
def draw(routes_name)
|
||||
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
|
||||
|
||||
draw_ee(routes_name)
|
||||
end
|
||||
|
||||
def draw_ee(routes_name)
|
||||
path = Rails.root.join("ee/config/routes/#{routes_name}.rb")
|
||||
|
||||
instance_eval(File.read(path)) if File.exist?(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue