From 6a2737e6a82875311f71f451939b2732562533d4 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Tue, 15 Nov 2016 09:39:45 +0100 Subject: WIP - refactor events to use a generic build entity for some of the hybrid events --- spec/serializers/analytics_build_entity_spec.rb | 6 +++--- spec/serializers/analytics_build_serializer_spec.rb | 6 ++---- spec/serializers/analytics_generic_serializer_spec.rb | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'spec/serializers') diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb index 24040034f68..9ac6f20fd3c 100644 --- a/spec/serializers/analytics_build_entity_spec.rb +++ b/spec/serializers/analytics_build_entity_spec.rb @@ -5,14 +5,14 @@ describe AnalyticsBuildEntity do described_class.new(build, request: double) end - context 'when build is a regular job' do + context 'build with an author' do let(:user) { create(:user) } let(:build) { create(:ci_build, author: user) } subject { entity.as_json } - it 'contains URLs' do - expect(subject).to include(:url, :branch_url, :commit_url) + it 'contains the URL' do + expect(subject).to include(:url) end it 'contains the author' do diff --git a/spec/serializers/analytics_build_serializer_spec.rb b/spec/serializers/analytics_build_serializer_spec.rb index 24fd94810d4..a0a9d9a5f12 100644 --- a/spec/serializers/analytics_build_serializer_spec.rb +++ b/spec/serializers/analytics_build_serializer_spec.rb @@ -3,12 +3,10 @@ require 'spec_helper' describe AnalyticsBuildSerializer do let(:serializer) do described_class - .new(project: project) - .represent(resource) + .new.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 @@ -18,7 +16,7 @@ describe AnalyticsBuildSerializer do it 'contains important elements of analyticsBuild' do expect(json) - .to include(:name, :branch, :short_sha, :date, :total_time, :url, :branch_url, :commit_url, :author) + .to include(:name, :branch, :short_sha, :date, :total_time, :url, :author) end end end diff --git a/spec/serializers/analytics_generic_serializer_spec.rb b/spec/serializers/analytics_generic_serializer_spec.rb index 24fd94810d4..4d523878015 100644 --- a/spec/serializers/analytics_generic_serializer_spec.rb +++ b/spec/serializers/analytics_generic_serializer_spec.rb @@ -1,15 +1,26 @@ require 'spec_helper' -describe AnalyticsBuildSerializer do +describe AnalyticsGenericSerializer do let(:serializer) do described_class .new(project: project) .represent(resource) end + let(:user) { create(:user) } let(:json) { serializer.as_json } let(:project) { create(:project) } - let(:resource) { create(:ci_build) } + let(:resource) { + { + 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 + } + } context 'when there is a single object provided' do it 'it generates payload for single object' do @@ -17,8 +28,7 @@ describe AnalyticsBuildSerializer do 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) + expect(json).to include(:title, :iid, :date, :total_time, :url, :author) end end end -- cgit v1.2.3