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
f1701c0f
Commit
f1701c0f
authored
Oct 17, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to add EE only route
And if it cannot find any routes, raise an error
parent
1581f75f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
doc/development/ee_features.md
doc/development/ee_features.md
+10
-5
lib/gitlab/patch/draw_route.rb
lib/gitlab/patch/draw_route.rb
+16
-4
No files found.
doc/development/ee_features.md
View file @
f1701c0f
...
@@ -334,12 +334,17 @@ full implementation details.
...
@@ -334,12 +334,17 @@ full implementation details.
### Code in `config/routes`
### Code in `config/routes`
When we add
`draw :admin`
in
`config/routes.rb`
, the application will
als
o
When we add
`draw :admin`
in
`config/routes.rb`
, the application will
try t
o
load the file located in
`config/routes/admin.rb`
, and also
load the file located in
`config/routes/admin.rb`
, and also
try to load the
`ee/config/routes/admin.rb`
if the file exists
.
file located in
`ee/config/routes/admin.rb`
.
So if we want to extend a particular route file, just add the same file
It should at least load one file, at most two files. If it cannot find any
located in
`ee/config/routes`
.
files, an error will be raised.
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`
.
### Code in `app/controllers/`
### Code in `app/controllers/`
...
...
lib/gitlab/patch/draw_route.rb
View file @
f1701c0f
...
@@ -5,16 +5,28 @@
...
@@ -5,16 +5,28 @@
module
Gitlab
module
Gitlab
module
Patch
module
Patch
module
DrawRoute
module
DrawRoute
RoutesNotFound
=
Class
.
new
(
StandardError
)
def
draw
(
routes_name
)
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
end
def
draw_ee
(
routes_name
)
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
end
end
end
...
...
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