diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-06-11 17:55:54 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-06-11 17:55:54 +0700 |
commit | 1b7e9d24015b29777e187048a5d350bd0f3cc99e (patch) | |
tree | 2564e1b668104d473e32b4307de68c1b6d76ea29 | |
parent | c327d02bd2e0e6b96c3c8448e043040914590b4d (diff) | |
download | gitlab-ce-master-ce.tar.gz |
Fix user nil exception in PipelineScheduleServicemaster-ce
Fixing nil exception
-rw-r--r-- | app/services/ci/pipeline_schedule_service.rb | 2 | ||||
-rw-r--r-- | spec/services/ci/pipeline_schedule_service_spec.rb | 8 |
2 files changed, 9 insertions, 1 deletions
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/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 |