Add job_entity_spec
This commit is contained in:
parent
66b3bd5e26
commit
137f74b563
|
|
@ -24,8 +24,12 @@ class JobEntity < Grape::Entity
|
|||
path_to(:play_namespace_project_job, build)
|
||||
end
|
||||
|
||||
expose :unschedule_path, if: -> (*) { scheduled? } do |build|
|
||||
path_to(:unschedule_namespace_project_job, build)
|
||||
end
|
||||
|
||||
expose :playable?, as: :playable
|
||||
expose :scheduled_at
|
||||
expose :scheduled_at, if: -> (*) { scheduled? }
|
||||
expose :created_at
|
||||
expose :updated_at
|
||||
expose :detailed_status, as: :status, with: DetailedStatusEntity
|
||||
|
|
@ -48,6 +52,10 @@ class JobEntity < Grape::Entity
|
|||
build.playable? && can?(request.current_user, :update_build, build)
|
||||
end
|
||||
|
||||
def scheduled?
|
||||
build.scheduled?
|
||||
end
|
||||
|
||||
def detailed_status
|
||||
build.detailed_status(request.current_user)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -109,6 +109,18 @@ describe JobEntity do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when job is scheduled' do
|
||||
let(:job) { create(:ci_build, :scheduled) }
|
||||
|
||||
it 'contains path to unschedule action' do
|
||||
expect(subject).to include(:unschedule_path)
|
||||
end
|
||||
|
||||
it 'contains scheduled_at' do
|
||||
expect(subject[:scheduled_at]).to eq(job.scheduled_at)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when job is generic commit status' do
|
||||
let(:job) { create(:generic_commit_status, target_url: 'http://google.com') }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue