includes last_pipeline
This commit is contained in:
parent
df6040bbd4
commit
17b9128b30
3 changed files with 5 additions and 4 deletions
|
@ -690,9 +690,7 @@ module API
|
|||
expose :id
|
||||
expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active
|
||||
expose :created_at, :updated_at, :deleted_at
|
||||
expose :last_pipeline, using: Entities::Pipeline do |pipeline_schedule|
|
||||
pipeline_schedule.pipelines&.last
|
||||
end
|
||||
expose :last_pipeline, using: Entities::Pipeline
|
||||
expose :owner, using: Entities::UserBasic
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module API
|
|||
get ':id/pipeline_schedules' do
|
||||
authorize! :read_pipeline_schedule, user_project
|
||||
|
||||
pipeline_schedules = user_project.pipeline_schedules.preload(:pipelines)
|
||||
pipeline_schedules = user_project.pipeline_schedules.includes(last_pipeline: {statuses: :latest})
|
||||
|
||||
present paginate(pipeline_schedules), with: Entities::PipelineSchedule
|
||||
end
|
||||
|
|
|
@ -31,6 +31,9 @@ describe API::PipelineSchedules do
|
|||
end.count
|
||||
|
||||
create_list(:ci_pipeline_schedule, 10, project: project, owner: developer)
|
||||
.each do |pipeline_schedule|
|
||||
pipeline_schedule.pipelines << build(:ci_pipeline, project: project)
|
||||
end
|
||||
|
||||
expect do
|
||||
get api("/projects/#{project.id}/pipeline_schedules", developer)
|
||||
|
|
Loading…
Reference in a new issue