Commit 855dbfcb authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'expose-created-at-in-groups-api' into 'master'

Expose created_at property in Groups API

See merge request gitlab-org/gitlab!27824
parents 2a5f09fa fb3ae25c
---
title: Expose created_at property in Groups API
merge_request: 27824
author:
type: added
...@@ -49,7 +49,8 @@ GET /groups ...@@ -49,7 +49,8 @@ GET /groups
"full_name": "Foobar Group", "full_name": "Foobar Group",
"full_path": "foo-bar", "full_path": "foo-bar",
"file_template_project_id": 1, "file_template_project_id": 1,
"parent_id": null "parent_id": null,
"created_at": "2020-01-15T12:36:29.590Z"
} }
] ]
``` ```
...@@ -85,6 +86,7 @@ GET /groups?statistics=true ...@@ -85,6 +86,7 @@ GET /groups?statistics=true
"full_path": "foo-bar", "full_path": "foo-bar",
"file_template_project_id": 1, "file_template_project_id": 1,
"parent_id": null, "parent_id": null,
"created_at": "2020-01-15T12:36:29.590Z",
"statistics": { "statistics": {
"storage_size" : 212, "storage_size" : 212,
"repository_size" : 33, "repository_size" : 33,
...@@ -157,7 +159,8 @@ GET /groups/:id/subgroups ...@@ -157,7 +159,8 @@ GET /groups/:id/subgroups
"full_name": "Foobar Group", "full_name": "Foobar Group",
"full_path": "foo-bar", "full_path": "foo-bar",
"file_template_project_id": 1, "file_template_project_id": 1,
"parent_id": 123 "parent_id": 123,
"created_at": "2020-01-15T12:36:29.590Z"
} }
] ]
``` ```
...@@ -282,6 +285,7 @@ Example response: ...@@ -282,6 +285,7 @@ Example response:
"runners_token": "ba324ca7b1c77fc20bb9", "runners_token": "ba324ca7b1c77fc20bb9",
"file_template_project_id": 1, "file_template_project_id": 1,
"parent_id": null, "parent_id": null,
"created_at": "2020-01-15T12:36:29.590Z",
"projects": [ "projects": [
{ {
"id": 7, "id": 7,
...@@ -591,6 +595,7 @@ Example response: ...@@ -591,6 +595,7 @@ Example response:
"full_path": "foo-bar", "full_path": "foo-bar",
"file_template_project_id": 1, "file_template_project_id": 1,
"parent_id": null, "parent_id": null,
"created_at": "2020-01-15T12:36:29.590Z",
"projects": [ "projects": [
{ {
"id": 9, "id": 9,
......
...@@ -19,6 +19,7 @@ module API ...@@ -19,6 +19,7 @@ module API
end end
expose :request_access_enabled expose :request_access_enabled
expose :full_name, :full_path expose :full_name, :full_path
expose :created_at
expose :parent_id expose :parent_id
expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
......
...@@ -71,6 +71,7 @@ describe API::Groups do ...@@ -71,6 +71,7 @@ describe API::Groups do
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['created_at']).to be_present
expect(json_response) expect(json_response)
.to satisfy_one { |group| group['name'] == group1.name } .to satisfy_one { |group| group['name'] == group1.name }
end end
...@@ -121,6 +122,15 @@ describe API::Groups do ...@@ -121,6 +122,15 @@ describe API::Groups do
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first).not_to include 'statistics' expect(json_response.first).not_to include 'statistics'
end end
it "includes a created_at timestamp" do
get api("/groups", user1)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['created_at']).to be_present
end
end end
context "when authenticated as admin" do context "when authenticated as admin" do
...@@ -152,6 +162,15 @@ describe API::Groups do ...@@ -152,6 +162,15 @@ describe API::Groups do
expect(json_response.first).not_to include('statistics') expect(json_response.first).not_to include('statistics')
end end
it "includes a created_at timestamp" do
get api("/groups", admin)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['created_at']).to be_present
end
it "includes statistics if requested" do it "includes statistics if requested" do
attributes = { attributes = {
storage_size: 1158, storage_size: 1158,
...@@ -357,6 +376,7 @@ describe API::Groups do ...@@ -357,6 +376,7 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include('runners_token') expect(json_response).not_to include('runners_token')
expect(json_response).to include('created_at')
end end
it 'returns only public projects in the group' do it 'returns only public projects in the group' do
...@@ -407,6 +427,7 @@ describe API::Groups do ...@@ -407,6 +427,7 @@ describe API::Groups do
expect(json_response['full_name']).to eq(group1.full_name) expect(json_response['full_name']).to eq(group1.full_name)
expect(json_response['full_path']).to eq(group1.full_path) expect(json_response['full_path']).to eq(group1.full_path)
expect(json_response['parent_id']).to eq(group1.parent_id) expect(json_response['parent_id']).to eq(group1.parent_id)
expect(json_response['created_at']).to be_present
expect(json_response['projects']).to be_an Array expect(json_response['projects']).to be_an Array
expect(json_response['projects'].length).to eq(2) expect(json_response['projects'].length).to eq(2)
expect(json_response['shared_projects']).to be_an Array expect(json_response['shared_projects']).to be_an Array
...@@ -613,6 +634,7 @@ describe API::Groups do ...@@ -613,6 +634,7 @@ describe API::Groups do
expect(json_response['subgroup_creation_level']).to eq("maintainer") expect(json_response['subgroup_creation_level']).to eq("maintainer")
expect(json_response['request_access_enabled']).to eq(true) expect(json_response['request_access_enabled']).to eq(true)
expect(json_response['parent_id']).to eq(nil) expect(json_response['parent_id']).to eq(nil)
expect(json_response['created_at']).to be_present
expect(json_response['projects']).to be_an Array expect(json_response['projects']).to be_an Array
expect(json_response['projects'].length).to eq(2) expect(json_response['projects'].length).to eq(2)
expect(json_response['shared_projects']).to be_an Array expect(json_response['shared_projects']).to be_an Array
......
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