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
a0655572
Commit
a0655572
authored
Sep 10, 2012
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Common errors method added
parent
915dac00
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
lib/api/helpers.rb
lib/api/helpers.rb
+8
-4
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+1
-1
No files found.
lib/api/helpers.rb
View file @
a0655572
...
@@ -31,22 +31,26 @@ module Gitlab
...
@@ -31,22 +31,26 @@ module Gitlab
# error helpers
# error helpers
def
forbidden!
def
forbidden!
error!
({
'message'
=>
'403 Forbidden'
}
,
403
)
render_api_error!
(
'403 Forbidden'
,
403
)
end
end
def
not_found!
(
resource
=
nil
)
def
not_found!
(
resource
=
nil
)
message
=
[
"404"
]
message
=
[
"404"
]
message
<<
resource
if
resource
message
<<
resource
if
resource
message
<<
"Not Found"
message
<<
"Not Found"
error!
({
'message'
=>
message
.
join
(
' '
)}
,
404
)
render_api_error!
(
message
.
join
(
' '
)
,
404
)
end
end
def
unauthorized!
def
unauthorized!
error!
({
'message'
=>
'401 Unauthorized'
}
,
401
)
render_api_error!
(
'401 Unauthorized'
,
401
)
end
end
def
not_allowed!
def
not_allowed!
error!
({
'message'
=>
'method not allowed'
},
405
)
render_api_error!
(
'Method Not Allowed'
,
405
)
end
def
render_api_error!
(
message
,
status
)
error!
({
'message'
=>
message
},
status
)
end
end
private
private
...
...
spec/requests/api/projects_spec.rb
View file @
a0655572
...
@@ -85,7 +85,7 @@ describe Gitlab::API do
...
@@ -85,7 +85,7 @@ describe Gitlab::API do
it
"should return a 404 error if not found"
do
it
"should return a 404 error if not found"
do
get
api
(
"/projects/42"
,
user
)
get
api
(
"/projects/42"
,
user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not
f
ound'
json_response
[
'message'
].
should
==
'404 Not
F
ound'
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