summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-28 21:10:51 +0200
committerMatija Čupić <matteeyah@gmail.com>2018-05-28 21:10:51 +0200
commitaac8d1f3363a87f0bcd31009aad41d577f0a3f67 (patch)
tree3f816f79b7a1ad2d18e1489cf90771fb965418cc
parent6e354cb642f911dc71be3d5368f066900fc25970 (diff)
downloadgitlab-ce-aac8d1f3363a87f0bcd31009aad41d577f0a3f67.tar.gz
Add check for nil auto_devops in Projects::UpdateService
-rw-r--r--app/services/projects/update_service.rb2
-rw-r--r--spec/services/projects/update_service_spec.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb
index 679f4a9cb62..1cea110d555 100644
--- a/app/services/projects/update_service.rb
+++ b/app/services/projects/update_service.rb
@@ -36,7 +36,7 @@ module Projects
end
def run_auto_devops_pipeline?
- return false if project.repository.gitlab_ci_yml || !project.auto_devops.previous_changes.include?('enabled')
+ return false if project.repository.gitlab_ci_yml || project.auto_devops.nil? || !project.auto_devops.previous_changes.include?('enabled')
project.auto_devops.enabled? || (project.auto_devops.enabled.nil? && Gitlab::CurrentSettings.auto_devops_enabled?)
end
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index 3e6073b9861..1f761bcbbad 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -275,6 +275,10 @@ describe Projects::UpdateService do
it { is_expected.to eq(false) }
end
+ context 'when auto devops is nil' do
+ it { is_expected.to eq(false) }
+ end
+
context 'when auto devops is explicitly enabled' do
before do
project.create_auto_devops!(enabled: true)