Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-09-07 16:08:51 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-09-07 16:08:51 +0300
commit83c1bb688c9fff5c146dcc5fb74fe74c1d948d34 (patch)
tree352d2754f7dbb9c5ee306eebc4bf1af90f901c41
parentd02f36d63c844c2a7ecd825df90745cb7951d982 (diff)
Add has_auto_devops_implicitly_disabled
-rw-r--r--app/helpers/auto_devops_helper.rb3
-rw-r--r--app/models/project.rb4
-rw-r--r--spec/models/project_spec.rb44
3 files changed, 49 insertions, 2 deletions
diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb
index e4907f631ef..4ff38f86b5f 100644
--- a/app/helpers/auto_devops_helper.rb
+++ b/app/helpers/auto_devops_helper.rb
@@ -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
diff --git a/app/models/project.rb b/app/models/project.rb
index b52b1e9049b..ca64fb173fb 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 75c99b62150..48fc77423ff 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -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) }