PipelineScheduleService return error
What does this MR do and why?
This MR addresses the first 2 of 4 follow-up issues created from !97857 (closed)
PipelineScheduleService was returning nil when project did not exist. This MR updates the service to return a ServiceResponse error instead.
Updates service authorization to align with Permission Development Guildlines. Adds ability check for current_user
on :play_pipeline_schedule
.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Open rails console(include Factory bot for easy creation of objects needed to test) create: a. a new project b. a Ci:PipelineSchedule with that project with the project user as the owner
- Delete the Project (created in 1a)
- Call
PipelineScheduleService
with the schedule created in step 1b - Observe the service returns a ServiceResponse.error
# Load a rails console:
$ bundle exec rails console
# Once console has loaded:
include FactoryBot::Syntax::Methods
project = create(:project)
pipeline_schedule = create(:ci_pipeline_schedule, project: project, owner: project.creator)
project.destroy
Ci::PipelineScheduleService.new(project, project.creator).execute(pipeline_schedule)
Related to #385579
Edited by Vlad Wolanyk