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
93d849be
Commit
93d849be
authored
Sep 22, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose project share expiration_date field on API
parent
00a7ca74
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
9 deletions
+16
-9
CHANGELOG
CHANGELOG
+2
-0
doc/api/projects.md
doc/api/projects.md
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/projects.rb
lib/api/projects.rb
+6
-5
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+6
-3
No files found.
CHANGELOG
View file @
93d849be
Please view this file on the master branch, on stable branches it's out of date.
v 8.13.0 (unreleased)
- Expose expires_at field when sharing project on API
v 8.12.0 (unreleased)
- Update the rouge gem to 2.0.6, which adds highlighting support for JSX, Prometheus, and others. !6251
...
...
doc/api/projects.md
View file @
93d849be
...
...
@@ -899,6 +899,7 @@ Parameters:
-
`id`
(required) - The ID or NAMESPACE/PROJECT_NAME of the project to be forked
-
`group_id`
(required) - The ID of a group
-
`group_access`
(required) - Level of permissions for sharing
-
`expires_at`
- Share expiration date in ISO 8601 format: 2016-09-26
## Hooks
...
...
lib/api/entities.rb
View file @
93d849be
...
...
@@ -343,7 +343,7 @@ module API
end
class
ProjectGroupLink
<
Grape
::
Entity
expose
:id
,
:project_id
,
:group_id
,
:group_access
expose
:id
,
:project_id
,
:group_id
,
:group_access
,
:expires_at
end
class
Todo
<
Grape
::
Entity
...
...
lib/api/projects.rb
View file @
93d849be
...
...
@@ -396,20 +396,21 @@ module API
# id (required) - The ID of a project
# group_id (required) - The ID of a group
# group_access (required) - Level of permissions for sharing
# expires_at (optional) - Share expiration date
#
# Example Request:
# POST /projects/:id/share
post
":id/share"
do
authorize!
:admin_project
,
user_project
required_attributes!
[
:group_id
,
:group_access
]
attrs
=
attributes_for_keys
[
:group_id
,
:group_access
,
:expires_at
]
unless
user_project
.
allowed_to_share_with_group?
return
render_api_error!
(
"The project sharing with group is disabled"
,
400
)
end
link
=
user_project
.
project_group_links
.
new
link
.
group_id
=
params
[
:group_id
]
link
.
group_access
=
params
[
:group_access
]
link
=
user_project
.
project_group_links
.
new
(
attrs
)
if
link
.
save
present
link
,
with:
Entities
::
ProjectGroupLink
else
...
...
spec/requests/api/projects_spec.rb
View file @
93d849be
...
...
@@ -761,13 +761,16 @@ describe API::API, api: true do
let
(
:group
)
{
create
(
:group
)
}
it
"shares project with group"
do
expires_at
=
10
.
days
.
from_now
.
to_date
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
,
group_access:
Gitlab
::
Access
::
DEVELOPER
post
api
(
"/projects/
#{
project
.
id
}
/share"
,
user
),
group_id:
group
.
id
,
group_access:
Gitlab
::
Access
::
DEVELOPER
,
expires_at:
expires_at
end
.
to
change
{
ProjectGroupLink
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
201
expect
(
json_response
[
'group_id'
]).
to
eq
group
.
id
expect
(
json_response
[
'group_access'
]).
to
eq
Gitlab
::
Access
::
DEVELOPER
expect
(
json_response
[
'group_id'
]).
to
eq
(
group
.
id
)
expect
(
json_response
[
'group_access'
]).
to
eq
(
Gitlab
::
Access
::
DEVELOPER
)
expect
(
json_response
[
'expires_at'
]).
to
eq
(
expires_at
.
to_s
)
end
it
"returns a 400 error when group id is not given"
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