diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2018-08-09 11:21:17 +0300 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2018-08-21 12:23:05 +0300 |
commit | 7308a9be1ea480584fad85dc5de569500fc3ceb7 (patch) | |
tree | e4a865be06da750f67d4cf73c4cf382356a041b8 | |
parent | cc9764acd049776a40b2188f72436b824f5b0d1a (diff) |
API: Add shared project's expiration date
-rw-r--r-- | changelogs/unreleased/api-shared_group_expires-at.yml | 5 | ||||
-rw-r--r-- | doc/api/groups.md | 6 | ||||
-rw-r--r-- | lib/api/entities.rb | 1 | ||||
-rw-r--r-- | spec/factories/project_group_links.rb | 1 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 16 |
5 files changed, 27 insertions, 2 deletions
diff --git a/changelogs/unreleased/api-shared_group_expires-at.yml b/changelogs/unreleased/api-shared_group_expires-at.yml new file mode 100644 index 00000000000..3d569de65fa --- /dev/null +++ b/changelogs/unreleased/api-shared_group_expires-at.yml @@ -0,0 +1,5 @@ +--- +title: 'API: Add expiration date for shared projects to the project entity' +merge_request: 21104 +author: Robert Schilling +type: added diff --git a/doc/api/groups.md b/doc/api/groups.md index 87be36cc815..64e0d78788d 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -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" } ] } diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 27f28e1df93..864640dcb69 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -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 diff --git a/spec/factories/project_group_links.rb b/spec/factories/project_group_links.rb index d5ace9425a0..59c77627ee5 100644 --- a/spec/factories/project_group_links.rb +++ b/spec/factories/project_group_links.rb @@ -2,5 +2,6 @@ FactoryBot.define do factory :project_group_link do project group + expires_at nil end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index eb41750bf47..e1b024a39f2 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -914,12 +914,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) |