Commit 3b179bc3 authored by James Lopez's avatar James Lopez

WIP - refactored events to use build serializer, related spec passing

parent 81d0146c
......@@ -2,17 +2,23 @@ class AnalyticsBuildEntity < Grape::Entity
include RequestAwareEntity
expose :name
expose :id
expose :ref, as: :branch
expose :short_sha
expose :started_at, as: :date
expose :duration, as: :total_time
expose :author, using: UserEntity
expose :branch do
expose :ref, as: :name
expose :url do |build|
url_to(:namespace_project_build, build)
url_to(:namespace_project_tree, build, build.ref)
end
end
expose :branch_url do |build|
url_to(:namespace_project_tree, build, build.ref)
expose :url do |build|
url_to(:namespace_project_build, build)
end
expose :commit_url do |build|
......
......@@ -30,7 +30,7 @@ module Gitlab
end
def test_events
@fetcher.fetch(stage: :test).each do |event|
@fetcher.fetch(stage: :test).map do |event|
parse_build_event(event)
end
end
......@@ -40,7 +40,7 @@ module Gitlab
end
def staging_events
@fetcher.fetch(stage: :staging).each do |event|
@fetcher.fetch(stage: :staging).map do |event|
parse_build_event(event)
end
end
......@@ -64,7 +64,7 @@ module Gitlab
def parse_build_event(event)
build = ::Ci::Build.find(event['id'])
#event['author_name'] = build.author.try(:name)
AnalyticsBuildSerializer.new(project: @project).represent(build).as_json
end
def first_time_reference_commit(commits, event)
......
......@@ -6,14 +6,19 @@ describe AnalyticsBuildEntity do
end
context 'when build is a regular job' do
let(:build) { create(:ci_build) }
let(:user) { create(:user) }
let(:build) { create(:ci_build, author: user) }
subject { entity.as_json }
it 'contains url to build page and retry action' do
it 'contains URLs' do
expect(subject).to include(:url, :branch_url, :commit_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/)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment