Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
50976c6f
Commit
50976c6f
authored
Oct 23, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow CE do nothing if route doesn't exist
parent
f4d06fad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
6 deletions
+33
-6
doc/development/ee_features.md
doc/development/ee_features.md
+5
-4
ee/config/routes/oauth.rb
ee/config/routes/oauth.rb
+2
-0
ee/lib/ee/gitlab/patch/draw_route.rb
ee/lib/ee/gitlab/patch/draw_route.rb
+16
-0
ee/spec/lib/gitlab/patch/draw_route_spec.rb
ee/spec/lib/gitlab/patch/draw_route_spec.rb
+5
-0
lib/gitlab/patch/draw_route.rb
lib/gitlab/patch/draw_route.rb
+4
-2
spec/fast_spec_helper.rb
spec/fast_spec_helper.rb
+1
-0
No files found.
doc/development/ee_features.md
View file @
50976c6f
...
...
@@ -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/`
...
...
ee/config/routes/oauth.rb
View file @
50976c6f
# frozen_string_literal: true
namespace
:oauth
do
scope
path:
'geo'
,
controller: :geo_auth
,
as: :geo
do
get
'auth'
...
...
ee/lib/ee/gitlab/patch/draw_route.rb
0 → 100644
View file @
50976c6f
# frozen_string_literal: true
module
EE
module
Gitlab
module
Patch
module
DrawRoute
extend
::
Gitlab
::
Utils
::
Override
override
:draw_ee
def
draw_ee
(
routes_name
)
draw_route
(
route_path
(
"ee/config/routes/
#{
routes_name
}
.rb"
))
end
end
end
end
end
ee/spec/lib/gitlab/patch/draw_route_spec.rb
View file @
50976c6f
...
...
@@ -39,4 +39,9 @@ describe Gitlab::Patch::DrawRoute do
.
with
(
File
.
read
(
subject
.
route_path
(
'ee/config/routes/admin.rb'
)))
.
once
end
it
'raises an error when nothing is drawn'
do
expect
{
subject
.
draw
(
:non_existing
)
}
.
to
raise_error
(
described_class
::
RoutesNotFound
)
end
end
lib/gitlab/patch/draw_route.rb
View file @
50976c6f
...
...
@@ -5,6 +5,8 @@
module
Gitlab
module
Patch
module
DrawRoute
prepend
EE
::
Gitlab
::
Patch
::
DrawRoute
RoutesNotFound
=
Class
.
new
(
StandardError
)
def
draw
(
routes_name
)
...
...
@@ -16,8 +18,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
)
...
...
spec/fast_spec_helper.rb
View file @
50976c6f
...
...
@@ -8,3 +8,4 @@ require_relative 'support/rspec'
require
'active_support/all'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'ee/lib'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment