Commit 542e26fe authored by Mathieu Parent's avatar Mathieu Parent

Add group full path to project's shared_with_groups

parent 6d6c2e95
---
title: Add group full path to project's shared_with_groups
merge_request: 24052
author: Mathieu Parent
type: added
...@@ -357,12 +357,14 @@ Example response: ...@@ -357,12 +357,14 @@ Example response:
{ {
"group_id": 4, "group_id": 4,
"group_name": "Twitter", "group_name": "Twitter",
"group_full_path": "twitter",
"group_access_level": 30, "group_access_level": 30,
"expires_at": null "expires_at": null
}, },
{ {
"group_id": 3, "group_id": 3,
"group_name": "Gitlab Org", "group_name": "Gitlab Org",
"group_full_path": "gitlab-org",
"group_access_level": 10, "group_access_level": 10,
"expires_at": "2018-08-14" "expires_at": "2018-08-14"
} }
......
...@@ -525,11 +525,13 @@ GET /projects/:id ...@@ -525,11 +525,13 @@ GET /projects/:id
{ {
"group_id": 4, "group_id": 4,
"group_name": "Twitter", "group_name": "Twitter",
"group_full_path": "twitter",
"group_access_level": 30 "group_access_level": 30
}, },
{ {
"group_id": 3, "group_id": 3,
"group_name": "Gitlab Org", "group_name": "Gitlab Org",
"group_full_path": "gitlab-org",
"group_access_level": 10 "group_access_level": 10
} }
], ],
......
...@@ -115,6 +115,9 @@ module API ...@@ -115,6 +115,9 @@ module API
expose :group_name do |group_link, options| expose :group_name do |group_link, options|
group_link.group.name group_link.group.name
end end
expose :group_full_path do |group_link, options|
group_link.group.full_path
end
expose :group_access, as: :group_access_level expose :group_access, as: :group_access_level
expose :expires_at expose :expires_at
end end
...@@ -277,7 +280,7 @@ module API ...@@ -277,7 +280,7 @@ module API
# N+1 is solved then by using `subject.tags.map(&:name)` # N+1 is solved then by using `subject.tags.map(&:name)`
# MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555 # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555
super(projects_relation).preload(:group) super(projects_relation).preload(:group)
.preload(project_group_links: :group, .preload(project_group_links: { group: :route },
fork_network: :root_project, fork_network: :root_project,
fork_network_member: :forked_from_project, fork_network_member: :forked_from_project,
forked_from_project: [:route, :forks, :tags, namespace: :route]) forked_from_project: [:route, :forks, :tags, namespace: :route])
......
...@@ -948,6 +948,7 @@ describe API::Projects do ...@@ -948,6 +948,7 @@ describe API::Projects do
expect(json_response['shared_with_groups'].length).to eq(1) 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_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_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_full_path']).to eq(group.full_path)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access) 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['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_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds)
...@@ -967,6 +968,7 @@ describe API::Projects do ...@@ -967,6 +968,7 @@ describe API::Projects do
expect(json_response['shared_with_groups'].length).to eq(1) 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_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_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_full_path']).to eq(group.full_path)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access) 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) expect(json_response['shared_with_groups'][0]['expires_at']).to eq(expires_at.to_s)
end end
......
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