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