Commit 137f74b5 authored by Shinya Maeda's avatar Shinya Maeda

Add job_entity_spec

parent 66b3bd5e
......@@ -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') }
......
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