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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
21ae36c6
Commit
21ae36c6
authored
Jan 07, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'update_api_messages' into 'master'
Update api messages See merge request !1364
parents
de6256ee
1fbeaa06
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
28 additions
and
25 deletions
+28
-25
CHANGELOG
CHANGELOG
+1
-0
lib/api/branches.rb
lib/api/branches.rb
+5
-4
lib/api/commits.rb
lib/api/commits.rb
+1
-1
lib/api/files.rb
lib/api/files.rb
+2
-2
lib/api/groups.rb
lib/api/groups.rb
+2
-2
lib/api/helpers.rb
lib/api/helpers.rb
+1
-1
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-1
lib/api/milestones.rb
lib/api/milestones.rb
+2
-2
lib/api/notes.rb
lib/api/notes.rb
+2
-2
lib/api/project_hooks.rb
lib/api/project_hooks.rb
+2
-2
lib/api/project_members.rb
lib/api/project_members.rb
+1
-1
lib/api/projects.rb
lib/api/projects.rb
+1
-1
lib/api/repositories.rb
lib/api/repositories.rb
+1
-1
spec/requests/api/fork_spec.rb
spec/requests/api/fork_spec.rb
+2
-2
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+2
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+2
-2
No files found.
CHANGELOG
View file @
21ae36c6
...
@@ -13,6 +13,7 @@ v 7.7.0
...
@@ -13,6 +13,7 @@ v 7.7.0
- Set project path instead of project name in create form
- Set project path instead of project name in create form
-
-
-
-
- Updates to the messages returned by API (sponsored by O'Reilly Media)
- New UI layout with side navigation
- New UI layout with side navigation
-
-
-
-
...
...
lib/api/branches.rb
View file @
21ae36c6
...
@@ -14,7 +14,8 @@ module API
...
@@ -14,7 +14,8 @@ module API
# Example Request:
# Example Request:
# GET /projects/:id/repository/branches
# GET /projects/:id/repository/branches
get
":id/repository/branches"
do
get
":id/repository/branches"
do
present
user_project
.
repository
.
branches
.
sort_by
(
&
:name
),
with:
Entities
::
RepoObject
,
project:
user_project
branches
=
user_project
.
repository
.
branches
.
sort_by
(
&
:name
)
present
branches
,
with:
Entities
::
RepoObject
,
project:
user_project
end
end
# Get a single branch
# Get a single branch
...
@@ -26,7 +27,7 @@ module API
...
@@ -26,7 +27,7 @@ module API
# GET /projects/:id/repository/branches/:branch
# GET /projects/:id/repository/branches/:branch
get
':id/repository/branches/:branch'
,
requirements:
{
branch:
/.*/
}
do
get
':id/repository/branches/:branch'
,
requirements:
{
branch:
/.*/
}
do
@branch
=
user_project
.
repository
.
branches
.
find
{
|
item
|
item
.
name
==
params
[
:branch
]
}
@branch
=
user_project
.
repository
.
branches
.
find
{
|
item
|
item
.
name
==
params
[
:branch
]
}
not_found!
(
"Branch
does not exist"
)
if
@branch
.
nil?
not_found!
(
"Branch
"
)
unless
@branch
present
@branch
,
with:
Entities
::
RepoObject
,
project:
user_project
present
@branch
,
with:
Entities
::
RepoObject
,
project:
user_project
end
end
...
@@ -43,7 +44,7 @@ module API
...
@@ -43,7 +44,7 @@ module API
authorize_admin_project
authorize_admin_project
@branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
@branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
not_found!
unless
@branch
not_found!
(
"Branch"
)
unless
@branch
protected_branch
=
user_project
.
protected_branches
.
find_by
(
name:
@branch
.
name
)
protected_branch
=
user_project
.
protected_branches
.
find_by
(
name:
@branch
.
name
)
user_project
.
protected_branches
.
create
(
name:
@branch
.
name
)
unless
protected_branch
user_project
.
protected_branches
.
create
(
name:
@branch
.
name
)
unless
protected_branch
...
@@ -63,7 +64,7 @@ module API
...
@@ -63,7 +64,7 @@ module API
authorize_admin_project
authorize_admin_project
@branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
@branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
not_found!
unless
@branch
not_found!
(
"Branch does not exist"
)
unless
@branch
protected_branch
=
user_project
.
protected_branches
.
find_by
(
name:
@branch
.
name
)
protected_branch
=
user_project
.
protected_branches
.
find_by
(
name:
@branch
.
name
)
protected_branch
.
destroy
if
protected_branch
protected_branch
.
destroy
if
protected_branch
...
...
lib/api/commits.rb
View file @
21ae36c6
...
@@ -108,7 +108,7 @@ module API
...
@@ -108,7 +108,7 @@ module API
if
note
.
save
if
note
.
save
present
note
,
with:
Entities
::
CommitNote
present
note
,
with:
Entities
::
CommitNote
else
else
not_found!
render_api_error!
(
"Failed to save note
#{
note
.
errors
.
messages
}
"
,
400
)
end
end
end
end
end
end
...
...
lib/api/files.rb
View file @
21ae36c6
...
@@ -35,7 +35,7 @@ module API
...
@@ -35,7 +35,7 @@ module API
file_path
=
attrs
.
delete
(
:file_path
)
file_path
=
attrs
.
delete
(
:file_path
)
commit
=
user_project
.
repository
.
commit
(
ref
)
commit
=
user_project
.
repository
.
commit
(
ref
)
not_found!
"Commit"
unless
commit
not_found!
'Commit'
unless
commit
blob
=
user_project
.
repository
.
blob_at
(
commit
.
sha
,
file_path
)
blob
=
user_project
.
repository
.
blob_at
(
commit
.
sha
,
file_path
)
...
@@ -53,7 +53,7 @@ module API
...
@@ -53,7 +53,7 @@ module API
commit_id:
commit
.
id
,
commit_id:
commit
.
id
,
}
}
else
else
render_api_error!
(
'File not found'
,
404
)
not_found!
'File'
end
end
end
end
...
...
lib/api/groups.rb
View file @
21ae36c6
...
@@ -54,7 +54,7 @@ module API
...
@@ -54,7 +54,7 @@ module API
if
@group
.
save
if
@group
.
save
present
@group
,
with:
Entities
::
Group
present
@group
,
with:
Entities
::
Group
else
else
not_found!
render_api_error!
(
"Failed to save group
#{
@group
.
errors
.
messages
}
"
,
400
)
end
end
end
end
...
@@ -97,7 +97,7 @@ module API
...
@@ -97,7 +97,7 @@ module API
if
result
if
result
present
group
present
group
else
else
not_found!
render_api_error!
(
"Failed to transfer project
#{
project
.
errors
.
messages
}
"
,
400
)
end
end
end
end
end
end
...
...
lib/api/helpers.rb
View file @
21ae36c6
...
@@ -42,7 +42,7 @@ module API
...
@@ -42,7 +42,7 @@ module API
def
user_project
def
user_project
@project
||=
find_project
(
params
[
:id
])
@project
||=
find_project
(
params
[
:id
])
@project
||
not_found!
@project
||
not_found!
(
"Project"
)
end
end
def
find_project
(
id
)
def
find_project
(
id
)
...
...
lib/api/merge_requests.rb
View file @
21ae36c6
...
@@ -233,7 +233,7 @@ module API
...
@@ -233,7 +233,7 @@ module API
if
note
.
save
if
note
.
save
present
note
,
with:
Entities
::
MRNote
present
note
,
with:
Entities
::
MRNote
else
else
render_
validation_error!
(
note
)
render_
api_error!
(
"Failed to save note
#{
note
.
errors
.
messages
}
"
,
400
)
end
end
end
end
end
end
...
...
lib/api/milestones.rb
View file @
21ae36c6
...
@@ -48,7 +48,7 @@ module API
...
@@ -48,7 +48,7 @@ module API
if
milestone
.
valid?
if
milestone
.
valid?
present
milestone
,
with:
Entities
::
Milestone
present
milestone
,
with:
Entities
::
Milestone
else
else
not_found!
render_api_error!
(
"Failed to create milestone
#{
milestone
.
errors
.
messages
}
"
,
400
)
end
end
end
end
...
@@ -72,7 +72,7 @@ module API
...
@@ -72,7 +72,7 @@ module API
if
milestone
.
valid?
if
milestone
.
valid?
present
milestone
,
with:
Entities
::
Milestone
present
milestone
,
with:
Entities
::
Milestone
else
else
not_found!
render_api_error!
(
"Failed to update milestone
#{
milestone
.
errors
.
messages
}
"
,
400
)
end
end
end
end
end
end
...
...
lib/api/notes.rb
View file @
21ae36c6
...
@@ -61,7 +61,7 @@ module API
...
@@ -61,7 +61,7 @@ module API
if
@note
.
valid?
if
@note
.
valid?
present
@note
,
with:
Entities
::
Note
present
@note
,
with:
Entities
::
Note
else
else
not_found!
not_found!
(
"Note
#{
@note
.
errors
.
messages
}
"
)
end
end
end
end
...
@@ -93,7 +93,7 @@ module API
...
@@ -93,7 +93,7 @@ module API
if
@note
.
valid?
if
@note
.
valid?
present
@note
,
with:
Entities
::
Note
present
@note
,
with:
Entities
::
Note
else
else
bad_request!
(
'Invalid note'
)
render_api_error!
(
"Failed to save note
#{
note
.
errors
.
messages
}
"
,
400
)
end
end
end
end
...
...
lib/api/project_hooks.rb
View file @
21ae36c6
...
@@ -53,7 +53,7 @@ module API
...
@@ -53,7 +53,7 @@ module API
if
@hook
.
errors
[
:url
].
present?
if
@hook
.
errors
[
:url
].
present?
error!
(
"Invalid url given"
,
422
)
error!
(
"Invalid url given"
,
422
)
end
end
not_found!
not_found!
(
"Project hook
#{
@hook
.
errors
.
messages
}
"
)
end
end
end
end
...
@@ -82,7 +82,7 @@ module API
...
@@ -82,7 +82,7 @@ module API
if
@hook
.
errors
[
:url
].
present?
if
@hook
.
errors
[
:url
].
present?
error!
(
"Invalid url given"
,
422
)
error!
(
"Invalid url given"
,
422
)
end
end
not_found!
not_found!
(
"Project hook
#{
@hook
.
errors
.
messages
}
"
)
end
end
end
end
...
...
lib/api/project_members.rb
View file @
21ae36c6
...
@@ -9,7 +9,7 @@ module API
...
@@ -9,7 +9,7 @@ module API
if
errors
[
:access_level
].
any?
if
errors
[
:access_level
].
any?
error!
(
errors
[
:access_level
],
422
)
error!
(
errors
[
:access_level
],
422
)
end
end
not_found!
not_found!
(
errors
)
end
end
end
end
...
...
lib/api/projects.rb
View file @
21ae36c6
...
@@ -227,7 +227,7 @@ module API
...
@@ -227,7 +227,7 @@ module API
render_api_error!
(
"Project already forked"
,
409
)
render_api_error!
(
"Project already forked"
,
409
)
end
end
else
else
not_found!
not_found!
(
"Source Project"
)
end
end
end
end
...
...
lib/api/repositories.rb
View file @
21ae36c6
...
@@ -133,7 +133,7 @@ module API
...
@@ -133,7 +133,7 @@ module API
env
[
'api.format'
]
=
:binary
env
[
'api.format'
]
=
:binary
present
data
present
data
else
else
not_found!
not_found!
(
'File'
)
end
end
end
end
...
...
spec/requests/api/fork_spec.rb
View file @
21ae36c6
...
@@ -44,7 +44,7 @@ describe API::API, api: true do
...
@@ -44,7 +44,7 @@ describe API::API, api: true do
it
'should fail on missing project access for the project to fork'
do
it
'should fail on missing project access for the project to fork'
do
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user3
)
post
api
(
"/projects/fork/
#{
project
.
id
}
"
,
user3
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not Found'
json_response
[
'message'
].
should
==
'404
Project
Not Found'
end
end
it
'should fail if forked project exists in the user namespace'
do
it
'should fail if forked project exists in the user namespace'
do
...
@@ -58,7 +58,7 @@ describe API::API, api: true do
...
@@ -58,7 +58,7 @@ describe API::API, api: true do
it
'should fail if project to fork from does not exist'
do
it
'should fail if project to fork from does not exist'
do
post
api
(
'/projects/fork/424242'
,
user
)
post
api
(
'/projects/fork/424242'
,
user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not Found'
json_response
[
'message'
].
should
==
'404
Project
Not Found'
end
end
end
end
...
...
spec/requests/api/groups_spec.rb
View file @
21ae36c6
...
@@ -91,7 +91,8 @@ describe API::API, api: true do
...
@@ -91,7 +91,8 @@ describe API::API, api: true do
it
"should not create group, duplicate"
do
it
"should not create group, duplicate"
do
post
api
(
"/groups"
,
admin
),
{
name:
"Duplicate Test"
,
path:
group2
.
path
}
post
api
(
"/groups"
,
admin
),
{
name:
"Duplicate Test"
,
path:
group2
.
path
}
response
.
status
.
should
==
404
response
.
status
.
should
==
400
response
.
message
.
should
==
"Bad Request"
end
end
it
"should return 400 bad request error if name not given"
do
it
"should return 400 bad request error if name not given"
do
...
...
spec/requests/api/projects_spec.rb
View file @
21ae36c6
...
@@ -289,7 +289,7 @@ describe API::API, api: true do
...
@@ -289,7 +289,7 @@ describe API::API, api: true 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 Found'
json_response
[
'message'
].
should
==
'404
Project
Not Found'
end
end
it
"should return a 404 error if user is not a member"
do
it
"should return a 404 error if user is not a member"
do
...
@@ -340,7 +340,7 @@ describe API::API, api: true do
...
@@ -340,7 +340,7 @@ describe API::API, api: true 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/events"
,
user
)
get
api
(
"/projects/42/events"
,
user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not Found'
json_response
[
'message'
].
should
==
'404
Project
Not Found'
end
end
it
"should return a 404 error if user is not a member"
do
it
"should return a 404 error if user is not a member"
do
...
...
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