Cleanup deploymentsd controller spec and use schema validation to test the output
This commit is contained in:
parent
88f69cbd8c
commit
5bf0441fd9
2 changed files with 62 additions and 9 deletions
|
@ -6,16 +6,15 @@ describe Projects::DeploymentsController do
|
|||
let(:user) { create(:user) }
|
||||
let(:project) { create(:empty_project) }
|
||||
let(:environment) { create(:environment, name: 'production', project: project) }
|
||||
let(:deployment) { create(:deployment, project: project, environment: environment) }
|
||||
|
||||
before do
|
||||
project.team << [user, :master]
|
||||
project.add_master(user)
|
||||
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns list of deployments withing last 8 hours' do
|
||||
it 'returns list of deployments from last 8 hours' do
|
||||
create(:deployment, environment: environment, created_at: 9.hours.ago)
|
||||
create(:deployment, environment: environment, created_at: 7.hours.ago)
|
||||
create(:deployment, environment: environment)
|
||||
|
@ -31,13 +30,9 @@ describe Projects::DeploymentsController do
|
|||
create(:deployment, environment: environment)
|
||||
|
||||
get :index, environment_params
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
deployments = json_response['deployments']
|
||||
deployment_info = deployments.first.with_indifferent_access
|
||||
|
||||
expect(deployments.count).to eq(1)
|
||||
expect(deployment_info).to include(:id, :iid, :sha, :ref, :tag, :created_at)
|
||||
expect(response).to match_response_schema('deployments')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
58
spec/fixtures/api/schemas/deployments.json
vendored
Normal file
58
spec/fixtures/api/schemas/deployments.json
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"deployments": {
|
||||
"items": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"iid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"last?": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ref": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"sha": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"sha",
|
||||
"created_at",
|
||||
"iid",
|
||||
"tag",
|
||||
"last?",
|
||||
"ref",
|
||||
"id"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"minItems": 1,
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deployments"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
Loading…
Reference in a new issue