BigW Consortium Gitlab

Commit d03e6878 by Kamil Trzcinski

Rename BuildEntity to JobEntity

parent 0a80e504
class BuildDetailsEntity < BuildEntity
class BuildDetailsEntity < JobEntity
expose :coverage, :erased_at, :duration
expose :tag_list, as: :tags
......
class BuildSerializer < BaseSerializer
entity BuildEntity
entity JobEntity
def represent_status(resource)
data = represent(resource, { only: [:status] })
......
......@@ -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|
......
......@@ -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
......
......@@ -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
......
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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
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