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
301a30e0
Commit
301a30e0
authored
Dec 13, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add project permissions to all project API endpoints
This standardizes all the project API formats. Also needed to support Huboard.
parent
1cf45407
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
+27
-3
CHANGELOG
CHANGELOG
+1
-0
projects.md
doc/api/projects.md
+10
-0
projects.rb
lib/api/projects.rb
+3
-3
projects_spec.rb
spec/requests/api/projects_spec.rb
+13
-0
No files found.
CHANGELOG
View file @
301a30e0
...
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.4.0 (unreleased)
- Implement new UI for group page
- Add project permissions to all project API endpoints (Stan Hu)
v 8.3.0
- Add CAS support (tduehr)
...
...
doc/api/projects.md
View file @
301a30e0
...
...
@@ -118,6 +118,16 @@ Parameters:
"path"
:
"brightbox"
,
"updated_at"
:
"2013-09-30T13:46:02Z"
},
"permissions"
:
{
"project_access"
:
{
"access_level"
:
10
,
"notification_level"
:
3
},
"group_access"
:
{
"access_level"
:
50
,
"notification_level"
:
3
}
},
"archived"
:
false
,
"avatar_url"
:
null
}
...
...
lib/api/projects.rb
View file @
301a30e0
...
...
@@ -25,7 +25,7 @@ module API
@projects
=
current_user
.
authorized_projects
@projects
=
filter_projects
(
@projects
)
@projects
=
paginate
@projects
present
@projects
,
with:
Entities
::
Project
present
@projects
,
with:
Entities
::
Project
WithAccess
,
user:
current_user
end
# Get an owned projects list for authenticated user
...
...
@@ -36,7 +36,7 @@ module API
@projects
=
current_user
.
owned_projects
@projects
=
filter_projects
(
@projects
)
@projects
=
paginate
@projects
present
@projects
,
with:
Entities
::
Project
present
@projects
,
with:
Entities
::
Project
WithAccess
,
user:
current_user
end
# Gets starred project for the authenticated user
...
...
@@ -59,7 +59,7 @@ module API
@projects
=
Project
.
all
@projects
=
filter_projects
(
@projects
)
@projects
=
paginate
@projects
present
@projects
,
with:
Entities
::
Project
present
@projects
,
with:
Entities
::
Project
WithAccess
,
user:
current_user
end
# Get a single project
...
...
spec/requests/api/projects_spec.rb
View file @
301a30e0
...
...
@@ -131,6 +131,7 @@ describe API::API, api: true do
expect
(
json_response
).
to
satisfy
do
|
response
|
response
.
one?
do
|
entry
|
entry
.
has_key?
(
'permissions'
)
&&
entry
[
'name'
]
==
project
.
name
&&
entry
[
'owner'
][
'username'
]
==
user
.
username
end
...
...
@@ -382,6 +383,18 @@ describe API::API, api: true do
end
describe
'permissions'
do
context
'all projects'
do
it
'Contains permission information'
do
project
.
team
<<
[
user
,
:master
]
get
api
(
"/projects"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
.
first
[
'permissions'
][
'project_access'
][
'access_level'
]).
to
eq
(
Gitlab
::
Access
::
MASTER
)
expect
(
json_response
.
first
[
'permissions'
][
'group_access'
]).
to
be_nil
end
end
context
'personal project'
do
it
'Sets project access and returns 200'
do
project
.
team
<<
[
user
,
:master
]
...
...
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