summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-06-11 18:03:40 +0700
committerShinya Maeda <shinya@gitlab.com>2019-06-11 18:03:40 +0700
commit7ac5dfc1e9ef4d4e3eb3ae04f6349cfe48a22e8d (patch)
tree166d4e0750e4fad2eb8f44dcf576ba42614df3e6
parentc327d02bd2e0e6b96c3c8448e043040914590b4d (diff)
downloadgitlab-ce-7ac5dfc1e9ef4d4e3eb3ae04f6349cfe48a22e8d.tar.gz
Fix pipeline schedule when owner is nilfix-pipeline-schedule-owner-is-nil
Fixing the bug
-rw-r--r--app/services/ci/pipeline_schedule_service.rb2
-rw-r--r--changelogs/unreleased/fix-pipeline-schedule-owner-is-nil.yml5
-rw-r--r--spec/services/ci/pipeline_schedule_service_spec.rb8
3 files changed, 14 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/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