Commit e922750e authored by Sean McGivern's avatar Sean McGivern

Merge branch 'api-shared_group_expires-at' into 'master'

API: Add shared project's expiration date

Closes #46107

See merge request gitlab-org/gitlab-ce!21104
parents 1bbe3945 7308a9be
Pipeline #28416902 passed with stages
in 56 minutes and 59 seconds
---
title: 'API: Add expiration date for shared projects to the project entity'
merge_request: 21104
author: Robert Schilling
type: added
......@@ -351,12 +351,14 @@ Example response:
{
"group_id": 4,
"group_name": "Twitter",
"group_access_level": 30
"group_access_level": 30,
"expires_at": null
},
{
"group_id": 3,
"group_name": "Gitlab Org",
"group_access_level": 10
"group_access_level": 10,
"expires_at": "2018-08-14"
}
]
}
......
......@@ -91,6 +91,7 @@ module API
group_link.group.name
end
expose :group_access, as: :group_access_level
expose :expires_at
end
class ProjectIdentity < Grape::Entity
......
......@@ -2,5 +2,6 @@ FactoryBot.define do
factory :project_group_link do
project
group
expires_at nil
end
end
......@@ -913,12 +913,28 @@ describe API::Projects do
expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
expect(json_response['shared_with_groups'][0]['expires_at']).to be_nil
expect(json_response['only_allow_merge_if_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds)
expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved)
expect(json_response['merge_method']).to eq(project.merge_method.to_s)
expect(json_response['readme_url']).to eq(project.readme_url)
end
it 'returns a group link with expiration date' do
group = create(:group)
expires_at = 5.days.from_now.to_date
link = create(:project_group_link, project: project, group: group, expires_at: expires_at)
get api("/projects/#{project.id}", user)
expect(json_response['shared_with_groups']).to be_an Array
expect(json_response['shared_with_groups'].length).to eq(1)
expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
expect(json_response['shared_with_groups'][0]['expires_at']).to eq(expires_at.to_s)
end
it 'returns a project by path name' do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment