Commit a0e8e0c7 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'expose-created_at-and-updated_at-in-environment-api' into 'master'

api: Expose created_at and updated_at in Environments API

See merge request gitlab-org/gitlab!71091
parents b5247dec 3e14312b
...@@ -64,6 +64,8 @@ Example of response ...@@ -64,6 +64,8 @@ Example of response
"slug": "review-fix-foo-dfjre3", "slug": "review-fix-foo-dfjre3",
"external_url": "https://review-fix-foo-dfjre3.gitlab.example.com", "external_url": "https://review-fix-foo-dfjre3.gitlab.example.com",
"state": "available", "state": "available",
"created_at": "2019-05-25T18:55:13.252Z",
"updated_at": "2019-05-27T18:55:13.252Z",
"last_deployment": { "last_deployment": {
"id": 100, "id": 100,
"iid": 34, "iid": 34,
...@@ -176,7 +178,9 @@ Example response: ...@@ -176,7 +178,9 @@ Example response:
"name": "deploy", "name": "deploy",
"slug": "deploy", "slug": "deploy",
"external_url": "https://deploy.gitlab.example.com", "external_url": "https://deploy.gitlab.example.com",
"state": "available" "state": "available",
"created_at": "2019-05-25T18:55:13.252Z",
"updated_at": "2019-05-27T18:55:13.252Z"
} }
``` ```
...@@ -210,7 +214,9 @@ Example response: ...@@ -210,7 +214,9 @@ Example response:
"name": "staging", "name": "staging",
"slug": "staging", "slug": "staging",
"external_url": "https://staging.gitlab.example.com", "external_url": "https://staging.gitlab.example.com",
"state": "available" "state": "available",
"created_at": "2019-05-25T18:55:13.252Z",
"updated_at": "2019-05-27T18:55:13.252Z"
} }
``` ```
...@@ -302,6 +308,8 @@ Example response: ...@@ -302,6 +308,8 @@ Example response:
"name": "deploy", "name": "deploy",
"slug": "deploy", "slug": "deploy",
"external_url": "https://deploy.gitlab.example.com", "external_url": "https://deploy.gitlab.example.com",
"state": "stopped" "state": "stopped",
"created_at": "2019-05-25T18:55:13.252Z",
"updated_at": "2019-05-27T18:55:13.252Z"
} }
``` ```
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
] ]
}, },
"logs_path": { "type": "string" }, "logs_path": { "type": "string" },
"created_at": { "type": "string", "format": "date-time" },
"updated_at": { "type": "string", "format": "date-time" } "updated_at": { "type": "string", "format": "date-time" }
}, },
"additionalProperties": false "additionalProperties": false
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module API module API
module Entities module Entities
class EnvironmentBasic < Grape::Entity class EnvironmentBasic < Grape::Entity
expose :id, :name, :slug, :external_url expose :id, :name, :slug, :external_url, :created_at, :updated_at
end end
end end
end end
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
"name", "name",
"slug", "slug",
"external_url", "external_url",
"last_deployment" "state",
"created_at",
"updated_at"
], ],
"properties": { "properties": {
"id": { "type": "integer" }, "id": { "type": "integer" },
...@@ -19,6 +21,9 @@ ...@@ -19,6 +21,9 @@
] ]
}, },
"state": { "type": "string" }, "state": { "type": "string" },
"created_at": { "type": "string", "format": "date-time" },
"updated_at": { "type": "string", "format": "date-time" },
"project": { "$ref": "project.json" },
"enable_advanced_logs_querying": { "type": "boolean" }, "enable_advanced_logs_querying": { "type": "boolean" },
"logs_api_path": { "type": "string" }, "logs_api_path": { "type": "string" },
"gitlab_managed_apps_logs_path": { "type": "string" } "gitlab_managed_apps_logs_path": { "type": "string" }
......
...@@ -18,6 +18,7 @@ RSpec.describe API::Environments do ...@@ -18,6 +18,7 @@ RSpec.describe API::Environments do
get api("/projects/#{project.id}/environments", user) get api("/projects/#{project.id}/environments", user)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/environments')
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.size).to eq(1) expect(json_response.size).to eq(1)
...@@ -167,6 +168,7 @@ RSpec.describe API::Environments do ...@@ -167,6 +168,7 @@ RSpec.describe API::Environments do
post api("/projects/#{project.id}/environments", user), params: { name: "mepmep" } post api("/projects/#{project.id}/environments", user), params: { name: "mepmep" }
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/environment')
expect(json_response['name']).to eq('mepmep') expect(json_response['name']).to eq('mepmep')
expect(json_response['slug']).to eq('mepmep') expect(json_response['slug']).to eq('mepmep')
expect(json_response['external']).to be nil expect(json_response['external']).to be nil
...@@ -212,6 +214,7 @@ RSpec.describe API::Environments do ...@@ -212,6 +214,7 @@ RSpec.describe API::Environments do
params: { name: 'Mepmep', external_url: url } params: { name: 'Mepmep', external_url: url }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/environment')
expect(json_response['name']).to eq('Mepmep') expect(json_response['name']).to eq('Mepmep')
expect(json_response['external_url']).to eq(url) expect(json_response['external_url']).to eq(url)
end end
...@@ -250,7 +253,7 @@ RSpec.describe API::Environments do ...@@ -250,7 +253,7 @@ RSpec.describe API::Environments do
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns a 200 for stopped environment' do it 'returns a 204 for stopped environment' do
environment.stop environment.stop
delete api("/projects/#{project.id}/environments/#{environment.id}", user) delete api("/projects/#{project.id}/environments/#{environment.id}", user)
...@@ -294,6 +297,7 @@ RSpec.describe API::Environments do ...@@ -294,6 +297,7 @@ RSpec.describe API::Environments do
it 'returns a 200' do it 'returns a 200' do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/environment')
end end
it 'actually stops the environment' do it 'actually stops the environment' do
...@@ -327,6 +331,7 @@ RSpec.describe API::Environments do ...@@ -327,6 +331,7 @@ RSpec.describe API::Environments do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/environment') expect(response).to match_response_schema('public_api/v4/environment')
expect(json_response['last_deployment']).to be_present
end end
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