BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d6cfc004
Commit
d6cfc004
authored
Oct 07, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch any undefined API routing and return 400 Bad Request
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
68ab7047
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
3 deletions
+9
-3
api.rb
lib/api/api.rb
+4
-0
users_spec.rb
spec/requests/api/users_spec.rb
+2
-2
routing_spec.rb
spec/routing/routing_spec.rb
+3
-1
No files found.
lib/api/api.rb
View file @
d6cfc004
...
...
@@ -73,5 +73,9 @@ module API
mount
::
API
::
Triggers
mount
::
API
::
Users
mount
::
API
::
Variables
route
:any
,
'*path'
do
error!
(
'400 Bad Request'
,
400
)
end
end
end
spec/requests/api/users_spec.rb
View file @
d6cfc004
...
...
@@ -90,9 +90,9 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
it
"returns a 40
4
if invalid ID"
do
it
"returns a 40
0
if invalid ID"
do
get
api
(
"/users/1ASDF"
,
user
)
expect
(
response
).
to
have_http_status
(
40
4
)
expect
(
response
).
to
have_http_status
(
40
0
)
end
end
...
...
spec/routing/routing_spec.rb
View file @
d6cfc004
...
...
@@ -266,7 +266,9 @@ describe "Groups", "routing" do
end
it
"also display group#show on the short path"
do
expect
(
get
(
'/1'
)).
to
route_to
(
'namespaces#show'
,
id:
'1'
)
allow
(
Group
).
to
receive
(
:find_by_path
).
and_return
(
true
)
expect
(
get
(
'/1'
)).
to
route_to
(
'groups#show'
,
id:
'1'
)
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