summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-14 11:52:29 +0100
committerJames Lopez <james@jameslopez.es>2016-11-17 08:22:58 +0100
commit81d0146c4cf0d34b1b81da770483ed864482149c (patch)
tree5c634b0fff5df0b5fe148a7cbbaee914b47cfcf5 /spec
parent1744d633eded81103ee4691e6980efb6930dc975 (diff)
downloadgitlab-ce-81d0146c4cf0d34b1b81da770483ed864482149c.tar.gz
WIP - refactoring URL builder and events presenter into serializers
Diffstat (limited to 'spec')
-rw-r--r--spec/serializers/analytics_build_entity_spec.rb22
-rw-r--r--spec/serializers/analytics_build_serializer_spec.rb24
2 files changed, 46 insertions, 0 deletions
diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb
new file mode 100644
index 00000000000..33653d5b1e0
--- /dev/null
+++ b/spec/serializers/analytics_build_entity_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe AnalyticsBuildEntity do
+ let(:entity) do
+ described_class.new(build, request: double)
+ end
+
+ context 'when build is a regular job' do
+ let(:build) { create(:ci_build) }
+
+ subject { entity.as_json }
+
+ it 'contains url to build page and retry action' do
+ expect(subject).to include(:url, :branch_url, :commit_url)
+ end
+
+ it 'does not contain sensitive information' do
+ expect(subject).not_to include(/token/)
+ expect(subject).not_to include(/variables/)
+ end
+ end
+end
diff --git a/spec/serializers/analytics_build_serializer_spec.rb b/spec/serializers/analytics_build_serializer_spec.rb
new file mode 100644
index 00000000000..24fd94810d4
--- /dev/null
+++ b/spec/serializers/analytics_build_serializer_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe AnalyticsBuildSerializer do
+ let(:serializer) do
+ described_class
+ .new(project: project)
+ .represent(resource)
+ end
+
+ let(:json) { serializer.as_json }
+ let(:project) { create(:project) }
+ let(:resource) { create(:ci_build) }
+
+ context 'when there is a single object provided' do
+ it 'it generates payload for single object' do
+ expect(json).to be_an_instance_of Hash
+ end
+
+ it 'contains important elements of analyticsBuild' do
+ expect(json)
+ .to include(:name, :branch, :short_sha, :date, :total_time, :url, :branch_url, :commit_url, :author)
+ end
+ end
+end