Skip to content
Snippets Groups Projects
Commit d03e6878 authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Rename BuildEntity to JobEntity

parent 0a80e504
No related branches found
No related tags found
No related merge requests found
class BuildDetailsEntity < BuildEntity
class BuildDetailsEntity < JobEntity
expose :coverage, :erased_at, :duration
expose :tag_list, as: :tags
 
Loading
Loading
class BuildSerializer < BaseSerializer
entity BuildEntity
entity JobEntity
 
def represent_status(resource)
data = represent(resource, { only: [:status] })
Loading
Loading
Loading
Loading
@@ -24,6 +24,6 @@ class DeploymentEntity < Grape::Entity
 
expose :user, using: UserEntity
expose :commit, using: CommitEntity
expose :deployable, using: BuildEntity
expose :manual_actions, using: BuildEntity
expose :deployable, using: JobEntity
expose :manual_actions, using: JobEntity
end
class BuildEntity < Grape::Entity
class JobEntity < Grape::Entity
include RequestAwareEntity
 
expose :id
expose :name
 
expose :build_path do |build|
build.external_url || path_to(:namespace_project_job, build)
build.target_url || path_to(:namespace_project_job, build)
end
 
expose :retry_path, if: -> (*) { retryable? } do |build|
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class JobGroupEntity < Grape::Entity
expose :name
expose :size
expose :detailed_status, as: :status, with: StatusEntity
expose :jobs, with: BuildEntity
expose :jobs, with: JobEntity
 
private
 
Loading
Loading
Loading
Loading
@@ -3,8 +3,8 @@ require 'spec_helper'
describe BuildDetailsEntity do
set(:user) { create(:admin) }
 
it 'inherits from BuildEntity' do
expect(described_class).to be < BuildEntity
it 'inherits from JobEntity' do
expect(described_class).to be < JobEntity
end
 
describe '#as_json' do
Loading
Loading
require 'spec_helper'
 
describe BuildEntity do
describe JobEntity do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:project) { build.project }
let(:job) { create(:ci_build) }
let(:project) { job.project }
let(:request) { double('request') }
 
before do
Loading
Loading
@@ -12,12 +12,12 @@ describe BuildEntity do
end
 
let(:entity) do
described_class.new(build, request: request)
described_class.new(job, request: request)
end
 
subject { entity.as_json }
 
it 'contains paths to build page action' do
it 'contains paths to job page action' do
expect(subject).to include(:build_path)
end
 
Loading
Loading
@@ -27,7 +27,7 @@ describe BuildEntity do
end
 
it 'contains whether it is playable' do
expect(subject[:playable]).to eq build.playable?
expect(subject[:playable]).to eq job.playable?
end
 
it 'contains timestamps' do
Loading
Loading
@@ -41,7 +41,7 @@ describe BuildEntity do
 
context 'when build is retryable' do
before do
build.update(status: :failed)
job.update(status: :failed)
end
 
it 'contains cancel path' do
Loading
Loading
@@ -51,7 +51,7 @@ describe BuildEntity do
 
context 'when build is cancelable' do
before do
build.update(status: :running)
job.update(status: :running)
end
 
it 'contains cancel path' do
Loading
Loading
@@ -59,7 +59,7 @@ describe BuildEntity do
end
end
 
context 'when build is a regular build' do
context 'when job is a regular job' do
it 'does not contain path to play action' do
expect(subject).not_to include(:play_path)
end
Loading
Loading
@@ -69,8 +69,8 @@ describe BuildEntity do
end
end
 
context 'when build is a manual action' do
let(:build) { create(:ci_build, :manual) }
context 'when job is a manual action' do
let(:job) { create(:ci_build, :manual) }
 
context 'when user is allowed to trigger action' do
before do
Loading
Loading
@@ -99,4 +99,25 @@ describe BuildEntity do
end
end
end
context 'when job is generic commit status' do
let(:job) { create(:generic_commit_status, target_url: 'http://google.com') }
it 'contains paths to target action' do
expect(subject).to include(:build_path)
end
it 'does not contain paths to other action paths' do
expect(subject).not_to include(:retry_path, :cancel_path, :play_path)
end
it 'contains timestamps' do
expect(subject).to include(:created_at, :updated_at)
end
it 'contains details' do
expect(subject).to include :status
expect(subject[:status]).to include :icon, :favicon, :text, :label
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment