Commit 83c1bb68 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Add has_auto_devops_implicitly_disabled

parent d02f36d6
......@@ -2,7 +2,6 @@ module AutoDevopsHelper
def show_auto_devops_callout?(project)
show_callout?('auto_devops_settings_dismissed') &&
can?(current_user, :admin_pipeline, project) &&
!current_application_settings.auto_devops_enabled? &&
project.auto_devops&.enabled.nil?
project.has_auto_devops_implicitly_disabled?
end
end
......@@ -477,6 +477,10 @@ class Project < ActiveRecord::Base
end
end
def has_auto_devops_implicitly_disabled?
auto_devops&.enabled.nil? && !current_application_settings.auto_devops_enabled?
end
def repository_storage_path
Gitlab.config.repositories.storages[repository_storage].try(:[], 'path')
end
......
......@@ -2607,6 +2607,50 @@ describe Project do
end
end
describe '#has_auto_devops_implicitly_disabled?' do
set(:project) { create(:project) }
context 'when enabled in settings' do
before do
stub_application_setting(auto_devops_enabled: true)
end
it 'does not have auto devops implicitly disabled' do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
context 'when disabled in settings' do
before do
stub_application_setting(auto_devops_enabled: false)
end
it 'auto devops is implicitly disabled' do
expect(project).to have_auto_devops_implicitly_disabled
end
context 'when explicitly disabled' do
before do
create(:project_auto_devops, project: project, enabled: false)
end
it 'does not have auto devops implicitly disabled' do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
context 'when explicitly enabled' do
before do
create(:project_auto_devops, project: project)
end
it 'does not have auto devops implicitly disabled' do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
end
end
context '#auto_devops_variables' do
set(:project) { create(:project) }
......
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