Commit 5bf0441f authored by Pawel Chojnacki's avatar Pawel Chojnacki

Cleanup deploymentsd controller spec and use schema validation to test the output

parent 88f69cbd
...@@ -6,16 +6,15 @@ describe Projects::DeploymentsController do ...@@ -6,16 +6,15 @@ describe Projects::DeploymentsController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:environment) { create(:environment, name: 'production', project: project) } let(:environment) { create(:environment, name: 'production', project: project) }
let(:deployment) { create(:deployment, project: project, environment: environment) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
describe 'GET #index' do 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: 9.hours.ago)
create(:deployment, environment: environment, created_at: 7.hours.ago) create(:deployment, environment: environment, created_at: 7.hours.ago)
create(:deployment, environment: environment) create(:deployment, environment: environment)
...@@ -31,13 +30,9 @@ describe Projects::DeploymentsController do ...@@ -31,13 +30,9 @@ describe Projects::DeploymentsController do
create(:deployment, environment: environment) create(:deployment, environment: environment)
get :index, environment_params 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(response).to be_ok
expect(deployment_info).to include(:id, :iid, :sha, :ref, :tag, :created_at) expect(response).to match_response_schema('deployments')
end end
end end
......
{
"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"
}
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