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
e666cf50
Commit
e666cf50
authored
Aug 03, 2017
by
Tony
Committed by
Toon Claes
Aug 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose more attributes to unauthenticated GET /projects/:id
parent
72360817
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
17 deletions
+37
-17
lib/api/entities.rb
lib/api/entities.rb
+11
-14
spec/requests/api/environments_spec.rb
spec/requests/api/environments_spec.rb
+8
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+9
-1
spec/requests/api/v3/projects_spec.rb
spec/requests/api/v3/projects_spec.rb
+9
-1
No files found.
lib/api/entities.rb
View file @
e666cf50
...
@@ -76,13 +76,6 @@ module API
...
@@ -76,13 +76,6 @@ module API
expose
:file_name_regex
,
:max_file_size
expose
:file_name_regex
,
:max_file_size
end
end
class
BasicProjectDetails
<
Grape
::
Entity
expose
:id
expose
:http_url_to_repo
,
:web_url
expose
:name
,
:name_with_namespace
expose
:path
,
:path_with_namespace
end
class
SharedGroup
<
Grape
::
Entity
class
SharedGroup
<
Grape
::
Entity
expose
:group_id
expose
:group_id
expose
:group_name
do
|
group_link
,
options
|
expose
:group_name
do
|
group_link
,
options
|
...
@@ -91,7 +84,16 @@ module API
...
@@ -91,7 +84,16 @@ module API
expose
:group_access
,
as: :group_access_level
expose
:group_access
,
as: :group_access_level
end
end
class
Project
<
Grape
::
Entity
class
BasicProjectDetails
<
Grape
::
Entity
expose
:id
,
:description
,
:default_branch
,
:tag_list
expose
:ssh_url_to_repo
,
:http_url_to_repo
,
:web_url
expose
:name
,
:name_with_namespace
expose
:path
,
:path_with_namespace
expose
:star_count
,
:forks_count
expose
:created_at
,
:last_activity_at
end
class
Project
<
BasicProjectDetails
include
::
API
::
Helpers
::
RelatedResourcesHelpers
include
::
API
::
Helpers
::
RelatedResourcesHelpers
expose
:_links
do
expose
:_links
do
...
@@ -124,12 +126,9 @@ module API
...
@@ -124,12 +126,9 @@ module API
end
end
end
end
expose
:id
,
:description
,
:default_branch
,
:tag_list
expose
:archived?
,
as: :archived
expose
:archived?
,
as: :archived
expose
:visibility
,
:ssh_url_to_repo
,
:http_url_to_repo
,
:web_url
expose
:visibility
expose
:owner
,
using:
Entities
::
UserBasic
,
unless:
->
(
project
,
options
)
{
project
.
group
}
expose
:owner
,
using:
Entities
::
UserBasic
,
unless:
->
(
project
,
options
)
{
project
.
group
}
expose
:name
,
:name_with_namespace
expose
:path
,
:path_with_namespace
expose
:container_registry_enabled
expose
:container_registry_enabled
# Expose old field names with the new permissions methods to keep API compatible
# Expose old field names with the new permissions methods to keep API compatible
...
@@ -139,7 +138,6 @@ module API
...
@@ -139,7 +138,6 @@ module API
expose
(
:jobs_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:builds
,
options
[
:current_user
])
}
expose
(
:jobs_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:builds
,
options
[
:current_user
])
}
expose
(
:snippets_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:snippets
,
options
[
:current_user
])
}
expose
(
:snippets_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:snippets
,
options
[
:current_user
])
}
expose
:created_at
,
:last_activity_at
expose
:shared_runners_enabled
expose
:shared_runners_enabled
expose
:lfs_enabled?
,
as: :lfs_enabled
expose
:lfs_enabled?
,
as: :lfs_enabled
expose
:creator_id
expose
:creator_id
...
@@ -150,7 +148,6 @@ module API
...
@@ -150,7 +148,6 @@ module API
expose
:avatar_url
do
|
user
,
options
|
expose
:avatar_url
do
|
user
,
options
|
user
.
avatar_url
(
only_path:
false
)
user
.
avatar_url
(
only_path:
false
)
end
end
expose
:star_count
,
:forks_count
expose
:open_issues_count
,
if:
lambda
{
|
project
,
options
|
project
.
feature_available?
(
:issues
,
options
[
:current_user
])
}
expose
:open_issues_count
,
if:
lambda
{
|
project
,
options
|
project
.
feature_available?
(
:issues
,
options
[
:current_user
])
}
expose
:runners_token
,
if:
lambda
{
|
_project
,
options
|
options
[
:user_can_admin_project
]
}
expose
:runners_token
,
if:
lambda
{
|
_project
,
options
|
options
[
:user_can_admin_project
]
}
expose
:public_builds
,
as: :public_jobs
expose
:public_builds
,
as: :public_jobs
...
...
spec/requests/api/environments_spec.rb
View file @
e666cf50
...
@@ -13,7 +13,14 @@ describe API::Environments do
...
@@ -13,7 +13,14 @@ describe API::Environments do
describe
'GET /projects/:id/environments'
do
describe
'GET /projects/:id/environments'
do
context
'as member of the project'
do
context
'as member of the project'
do
it
'returns project environments'
do
it
'returns project environments'
do
project_data_keys
=
%w(id http_url_to_repo web_url name name_with_namespace path path_with_namespace)
project_data_keys
=
%w(
id description default_branch tag_list
ssh_url_to_repo http_url_to_repo web_url
name name_with_namespace
path path_with_namespace
star_count forks_count
created_at last_activity_at
)
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
...
...
spec/requests/api/projects_spec.rb
View file @
e666cf50
...
@@ -186,7 +186,14 @@ describe API::Projects do
...
@@ -186,7 +186,14 @@ describe API::Projects do
context
'and with simple=true'
do
context
'and with simple=true'
do
it
'returns a simplified version of all the projects'
do
it
'returns a simplified version of all the projects'
do
expected_keys
=
%w(id http_url_to_repo web_url name name_with_namespace path path_with_namespace)
expected_keys
=
%w(
id description default_branch tag_list
ssh_url_to_repo http_url_to_repo web_url
name name_with_namespace
path path_with_namespace
star_count forks_count
created_at last_activity_at
)
get
api
(
'/projects?simple=true'
,
user
)
get
api
(
'/projects?simple=true'
,
user
)
...
@@ -689,6 +696,7 @@ describe API::Projects do
...
@@ -689,6 +696,7 @@ describe API::Projects do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
public_project
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
public_project
.
id
)
expect
(
json_response
[
'description'
]).
to
eq
(
public_project
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
public_project
.
description
)
expect
(
json_response
[
'default_branch'
]).
to
eq
(
public_project
.
default_branch
)
expect
(
json_response
.
keys
).
not_to
include
(
'permissions'
)
expect
(
json_response
.
keys
).
not_to
include
(
'permissions'
)
end
end
end
end
...
...
spec/requests/api/v3/projects_spec.rb
View file @
e666cf50
...
@@ -82,7 +82,14 @@ describe API::V3::Projects do
...
@@ -82,7 +82,14 @@ describe API::V3::Projects do
context
'GET /projects?simple=true'
do
context
'GET /projects?simple=true'
do
it
'returns a simplified version of all the projects'
do
it
'returns a simplified version of all the projects'
do
expected_keys
=
%w(id http_url_to_repo web_url name name_with_namespace path path_with_namespace)
expected_keys
=
%w(
id description default_branch tag_list
ssh_url_to_repo http_url_to_repo web_url
name name_with_namespace
path path_with_namespace
star_count forks_count
created_at last_activity_at
)
get
v3_api
(
'/projects?simple=true'
,
user
)
get
v3_api
(
'/projects?simple=true'
,
user
)
...
@@ -644,6 +651,7 @@ describe API::V3::Projects do
...
@@ -644,6 +651,7 @@ describe API::V3::Projects do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
public_project
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
public_project
.
id
)
expect
(
json_response
[
'description'
]).
to
eq
(
public_project
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
public_project
.
description
)
expect
(
json_response
[
'default_branch'
]).
to
eq
(
public_project
.
default_branch
)
expect
(
json_response
.
keys
).
not_to
include
(
'permissions'
)
expect
(
json_response
.
keys
).
not_to
include
(
'permissions'
)
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