includes last_pipeline

This commit is contained in:
Shinya Maeda 2017-05-17 22:58:23 +09:00
parent df6040bbd4
commit 17b9128b30
3 changed files with 5 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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)