From 7ac5dfc1e9ef4d4e3eb3ae04f6349cfe48a22e8d Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 11 Jun 2019 18:03:40 +0700 Subject: Fix pipeline schedule when owner is nil Fixing the bug --- app/services/ci/pipeline_schedule_service.rb | 2 +- changelogs/unreleased/fix-pipeline-schedule-owner-is-nil.yml | 5 +++++ spec/services/ci/pipeline_schedule_service_spec.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/fix-pipeline-schedule-owner-is-nil.yml diff --git a/app/services/ci/pipeline_schedule_service.rb b/app/services/ci/pipeline_schedule_service.rb index 387d0351490..5b5e9a26520 100644 --- a/app/services/ci/pipeline_schedule_service.rb +++ b/app/services/ci/pipeline_schedule_service.rb @@ -7,7 +7,7 @@ module Ci # Otherwise, multiple pipelines could be created in a short interval. schedule.schedule_next_run! - RunPipelineScheduleWorker.perform_async(schedule.id, schedule.owner.id) + RunPipelineScheduleWorker.perform_async(schedule.id, schedule.owner&.id) end end end diff --git a/changelogs/unreleased/fix-pipeline-schedule-owner-is-nil.yml b/changelogs/unreleased/fix-pipeline-schedule-owner-is-nil.yml new file mode 100644 index 00000000000..5c8644d2860 --- /dev/null +++ b/changelogs/unreleased/fix-pipeline-schedule-owner-is-nil.yml @@ -0,0 +1,5 @@ +--- +title: Fix pipeline schedules when owner is nil +merge_request: +author: +type: fixed diff --git a/spec/services/ci/pipeline_schedule_service_spec.rb b/spec/services/ci/pipeline_schedule_service_spec.rb index f2ac53cb25a..867ed0acc0d 100644 --- a/spec/services/ci/pipeline_schedule_service_spec.rb +++ b/spec/services/ci/pipeline_schedule_service_spec.rb @@ -24,5 +24,13 @@ describe Ci::PipelineScheduleService do subject end + + context 'when owner is nil' do + let(:schedule) { create(:ci_pipeline_schedule, project: project, owner: nil) } + + it 'does not raise an error' do + expect { subject }.not_to raise_error + end + end end end -- cgit v1.2.1