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
Jérome Perrin
gitlab-ce
Commits
928b7f3b
Commit
928b7f3b
authored
Mar 17, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for API project permissions info
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
0ea0e542
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
lib/api/entities.rb
lib/api/entities.rb
+3
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+23
-0
No files found.
lib/api/entities.rb
View file @
928b7f3b
...
@@ -181,9 +181,11 @@ module API
...
@@ -181,9 +181,11 @@ module API
end
end
expose
:group_access
,
using:
Entities
::
GroupAccess
do
|
project
,
options
|
expose
:group_access
,
using:
Entities
::
GroupAccess
do
|
project
,
options
|
if
project
.
group
project
.
group
.
users_groups
.
find_by
(
user_id:
options
[
:user
].
id
)
project
.
group
.
users_groups
.
find_by
(
user_id:
options
[
:user
].
id
)
end
end
end
end
end
end
end
end
end
end
end
spec/requests/api/projects_spec.rb
View file @
928b7f3b
...
@@ -259,6 +259,7 @@ describe API::API do
...
@@ -259,6 +259,7 @@ describe API::API do
describe
"GET /projects/:id"
do
describe
"GET /projects/:id"
do
before
{
project
}
before
{
project
}
before
{
users_project
}
it
"should return a project by id"
do
it
"should return a project by id"
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
...
@@ -284,6 +285,28 @@ describe API::API do
...
@@ -284,6 +285,28 @@ describe API::API do
get
api
(
"/projects/
#{
project
.
id
}
"
,
other_user
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
other_user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
end
end
describe
'permissions'
do
context
'personal project'
do
before
{
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
}
it
{
response
.
status
.
should
==
200
}
it
{
json_response
[
'permissions'
][
"project_access"
][
"access_level"
].
should
==
Gitlab
::
Access
::
MASTER
}
it
{
json_response
[
'permissions'
][
"group_access"
].
should
be_nil
}
end
context
'group project'
do
before
do
project2
=
create
(
:project
,
group:
create
(
:group
))
project2
.
group
.
add_owner
(
user
)
get
api
(
"/projects/
#{
project2
.
id
}
"
,
user
)
end
it
{
response
.
status
.
should
==
200
}
it
{
json_response
[
'permissions'
][
"project_access"
].
should
be_nil
}
it
{
json_response
[
'permissions'
][
"group_access"
][
"access_level"
].
should
==
Gitlab
::
Access
::
OWNER
}
end
end
end
end
describe
"GET /projects/:id/events"
do
describe
"GET /projects/:id/events"
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