Commit 17b9128b authored by Shinya Maeda's avatar Shinya Maeda

includes last_pipeline

parent df6040bb
......@@ -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)
......
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