Commit 636d7038 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '46452-nomethoderror-undefined-method-previous_changes-for-nil-nilclass' into 'master'

Resolve "NoMethodError: undefined method `previous_changes' for nil:NilClass"

Closes #46452

See merge request gitlab-org/gitlab-ce!19190
parents 9ca8d88b 291dc5a2
......@@ -38,7 +38,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&.previous_changes&.include?('enabled')
project.auto_devops.enabled? || (project.auto_devops.enabled.nil? && Gitlab::CurrentSettings.auto_devops_enabled?)
end
......
---
title: Check for nil AutoDevOps when saving project CI/CD settings.
merge_request: 19190
author:
type: fixed
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment