Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-14 20:05:13 +0300
committerJames Lopez <james@jameslopez.es>2016-11-17 10:22:58 +0300
commit0ddf825ddf7bc480004919762b187390d0b900e9 (patch)
tree15dcfd21cec09e5e39a75216a88f1fce51b54ac9 /spec/serializers
parent3b179bc37b940521522af6d8bf6762c2a9a0e251 (diff)
WIP - adding a generic entity serializer that should accept a Hash coming from Arel
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/analytics_generic_entity_spec.rb39
-rw-r--r--spec/serializers/analytics_generic_serializer_spec.rb24
2 files changed, 63 insertions, 0 deletions
diff --git a/spec/serializers/analytics_generic_entity_spec.rb b/spec/serializers/analytics_generic_entity_spec.rb
new file mode 100644
index 00000000000..a09dae4520c
--- /dev/null
+++ b/spec/serializers/analytics_generic_entity_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+describe AnalyticsGenericEntity do
+ let(:user) { create(:user) }
+ let(:entity_hash) {
+ {
+ total_time: "172802.724419",
+ title: "Eos voluptatem inventore in sed.",
+ iid: "1",
+ id: "1",
+ created_at: "2016-11-12 15:04:02.948604",
+ author: user,
+ entity: :merge_request
+ }
+ }
+
+ let(:project) { create(:empty_project) }
+
+ let(:entity) do
+ described_class.new(entity_hash, request: double, project: project)
+ end
+
+ context 'generic entity' do
+ subject { entity.as_json }
+
+ it 'contains the entity URL' do
+ expect(subject).to include(:url)
+ end
+
+ it 'contains the author' do
+ expect(subject).to include(:author)
+ 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_generic_serializer_spec.rb b/spec/serializers/analytics_generic_serializer_spec.rb
new file mode 100644
index 00000000000..24fd94810d4
--- /dev/null
+++ b/spec/serializers/analytics_generic_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