summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorPeter Leitzen <pleitzen@gitlab.com>2018-10-10 11:43:02 +0200
committerPeter Leitzen <pleitzen@gitlab.com>2018-10-10 15:59:02 +0200
commit99a38a73a3f1f8d817e43c96ff20337a6832cc21 (patch)
treedf622f09039f469a9de8d1758489887454d8f5d6 /spec/serializers
parent75723034cee27d387d7ac7edb88d1520bb3a6b7b (diff)
downloadgitlab-ce-99a38a73a3f1f8d817e43c96ff20337a6832cc21.tar.gz
Enhance and test JSON schema for deployments
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/deployment_serializer_spec.rb35
1 files changed, 35 insertions, 0 deletions
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