Commit 87140a92 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'add-scheduled-flag-to-job-entity' into 'master'

Add scheduled flag to job entity

See merge request gitlab-org/gitlab-ce!22710
parents 74c79123 cb0b16eb
...@@ -12,7 +12,8 @@ class BuildActionEntity < Grape::Entity ...@@ -12,7 +12,8 @@ class BuildActionEntity < Grape::Entity
end end
expose :playable?, as: :playable expose :playable?, as: :playable
expose :scheduled_at, if: -> (build) { build.scheduled? } expose :scheduled?, as: :scheduled
expose :scheduled_at, if: -> (*) { scheduled? }
expose :unschedule_path, if: -> (build) { build.scheduled? } do |build| expose :unschedule_path, if: -> (build) { build.scheduled? } do |build|
unschedule_project_job_path(build.project, build) unschedule_project_job_path(build.project, build)
...@@ -25,4 +26,8 @@ class BuildActionEntity < Grape::Entity ...@@ -25,4 +26,8 @@ class BuildActionEntity < Grape::Entity
def playable? def playable?
build.playable? && can?(request.current_user, :update_build, build) build.playable? && can?(request.current_user, :update_build, build)
end end
def scheduled?
build.scheduled?
end
end end
...@@ -33,6 +33,7 @@ class JobEntity < Grape::Entity ...@@ -33,6 +33,7 @@ class JobEntity < Grape::Entity
end end
expose :playable?, as: :playable expose :playable?, as: :playable
expose :scheduled?, as: :scheduled
expose :scheduled_at, if: -> (*) { scheduled? } expose :scheduled_at, if: -> (*) { scheduled? }
expose :created_at expose :created_at
expose :updated_at expose :updated_at
......
---
title: Add scheduled flag to job entity
merge_request: 22710
author:
type: other
...@@ -26,6 +26,10 @@ describe BuildActionEntity do ...@@ -26,6 +26,10 @@ describe BuildActionEntity do
context 'when job is scheduled' do context 'when job is scheduled' do
let(:job) { create(:ci_build, :scheduled) } let(:job) { create(:ci_build, :scheduled) }
it 'returns scheduled' do
expect(subject[:scheduled]).to be_truthy
end
it 'returns scheduled_at' do it 'returns scheduled_at' do
expect(subject[:scheduled_at]).to eq(job.scheduled_at) expect(subject[:scheduled_at]).to eq(job.scheduled_at)
end end
......
...@@ -117,6 +117,7 @@ describe JobEntity do ...@@ -117,6 +117,7 @@ describe JobEntity do
end end
it 'contains scheduled_at' do it 'contains scheduled_at' do
expect(subject[:scheduled]).to be_truthy
expect(subject[:scheduled_at]).to eq(job.scheduled_at) expect(subject[:scheduled_at]).to eq(job.scheduled_at)
end 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