diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-10-10 15:35:15 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-10-10 15:35:15 +0000 |
commit | b3dfbb8d6b94123c713d95bbf8d115c8d24f4955 (patch) | |
tree | 0a90d28d8709db23d2e781e21353b0dc487c1dde | |
parent | 8f13e0710cb457a17fceeb4e87c2efdd2df8ae19 (diff) | |
parent | 99a38a73a3f1f8d817e43c96ff20337a6832cc21 (diff) | |
download | gitlab-ce-b3dfbb8d6b94123c713d95bbf8d115c8d24f4955.tar.gz |
Merge branch 'enhance-deployment-json-schema' into 'master'
Enhance and test JSON schema for deployments
See merge request gitlab-org/gitlab-ce!22266
-rw-r--r-- | spec/fixtures/api/schemas/deployment.json | 27 | ||||
-rw-r--r-- | spec/fixtures/api/schemas/entities/commit.json | 5 | ||||
-rw-r--r-- | spec/serializers/deployment_serializer_spec.rb | 35 |
3 files changed, 62 insertions, 5 deletions
diff --git a/spec/fixtures/api/schemas/deployment.json b/spec/fixtures/api/schemas/deployment.json index 8c8cdf8bcb2..44835386cfc 100644 --- a/spec/fixtures/api/schemas/deployment.json +++ b/spec/fixtures/api/schemas/deployment.json @@ -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 } diff --git a/spec/fixtures/api/schemas/entities/commit.json b/spec/fixtures/api/schemas/entities/commit.json index 686d29c97d2..324702e3f94 100644 --- a/spec/fixtures/api/schemas/entities/commit.json +++ b/spec/fixtures/api/schemas/entities/commit.json @@ -17,11 +17,10 @@ "author": { "oneOf": [ { "type": "null" }, - { "type": "user.json" } + { "$ref": "user.json" } ] } - }, - "additionalProperties": false + } } ] } diff --git a/spec/serializers/deployment_serializer_spec.rb b/spec/serializers/deployment_serializer_spec.rb new file mode 100644 index 00000000000..4834f5ede3c --- /dev/null +++ b/spec/serializers/deployment_serializer_spec.rb @@ -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 |