Enhance and test JSON schema for deployments
This commit is contained in:
parent
75723034ce
commit
99a38a73a3
3 changed files with 62 additions and 5 deletions
27
spec/fixtures/api/schemas/deployment.json
vendored
27
spec/fixtures/api/schemas/deployment.json
vendored
|
@ -20,12 +20,35 @@
|
|||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": { "type": "string" }
|
||||
"name": { "type": "string" },
|
||||
"ref_path": { "type": "string" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sha": { "type": "string" },
|
||||
"tag": { "type": "boolean" }
|
||||
"tag": { "type": "boolean" },
|
||||
"user": {
|
||||
"oneOf": [
|
||||
{ "type": "null" },
|
||||
{ "$ref": "entities/user.json" }
|
||||
]
|
||||
},
|
||||
"commit": {
|
||||
"oneOf": [
|
||||
{ "type": "null" },
|
||||
{ "$ref": "entities/commit.json" }
|
||||
]
|
||||
},
|
||||
"deployable": {
|
||||
"oneOf": [
|
||||
{ "type": "null" },
|
||||
{ "$ref": "job/job.json" }
|
||||
]
|
||||
},
|
||||
"manual_actions": {
|
||||
"type": "array",
|
||||
"items": { "$ref": "job/job.json" }
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
"author": {
|
||||
"oneOf": [
|
||||
{ "type": "null" },
|
||||
{ "type": "user.json" }
|
||||
{ "$ref": "user.json" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
35
spec/serializers/deployment_serializer_spec.rb
Normal file
35
spec/serializers/deployment_serializer_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe DeploymentSerializer do
|
||||
set(:project) { create(:project, :repository) }
|
||||
set(:user) { create(:user, email: project.commit.author_email) }
|
||||
|
||||
let(:resource) { create(:deployment, project: project, sha: project.commit.id) }
|
||||
let(:serializer) { described_class.new(request) }
|
||||
|
||||
shared_examples 'json schema' do
|
||||
let(:json_entity) { subject.as_json }
|
||||
|
||||
it 'matches deployment entity schema' do
|
||||
expect(json_entity).to match_schema('deployment')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#represent' do
|
||||
subject { serializer.represent(resource) }
|
||||
|
||||
let(:request) { { project: project, current_user: user } }
|
||||
|
||||
it_behaves_like 'json schema'
|
||||
end
|
||||
|
||||
describe '#represent_concise' do
|
||||
subject { serializer.represent_concise(resource) }
|
||||
|
||||
let(:request) { { project: project } }
|
||||
|
||||
it_behaves_like 'json schema'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue