summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-05-03 14:37:01 +0200
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-03 14:37:19 +0200
commitaf15b6f0e144762a38591c53b970e312c35fe65f (patch)
tree3f391685ba936e084dad816b78f1c82c7fc0d41a /app
parentbf790c26c58e214c27132e7a54fdf4a4cc77bdaf (diff)
downloadgitlab-ce-af15b6f0e144762a38591c53b970e312c35fe65f.tar.gz
Fix Project#group_runners_enabled as it was doing nothing
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb7
-rw-r--r--app/models/project_ci_cd_setting.rb2
-rw-r--r--app/services/ci/register_job_service.rb5
3 files changed, 11 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 8abbb92da62..50c404c300a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -234,7 +234,7 @@ class Project < ActiveRecord::Base
has_many :custom_attributes, class_name: 'ProjectCustomAttribute'
has_many :project_badges, class_name: 'ProjectBadge'
- has_one :ci_cd_settings, class_name: 'ProjectCiCdSetting'
+ has_one :ci_cd_settings, class_name: 'ProjectCiCdSetting', inverse_of: :project, autosave: true
accepts_nested_attributes_for :variables, allow_destroy: true
accepts_nested_attributes_for :project_feature, update_only: true
@@ -331,6 +331,11 @@ class Project < ActiveRecord::Base
scope :with_issues_available_for_user, ->(current_user) { with_feature_available_for_user(:issues, current_user) }
scope :with_merge_requests_enabled, -> { with_feature_enabled(:merge_requests) }
+ scope :with_group_runners_enabled, -> do
+ joins(:ci_cd_settings)
+ .where(project_ci_cd_settings: { group_runners_enabled: true })
+ end
+
enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 }
chronic_duration_attr :build_timeout_human_readable, :build_timeout, default: 3600
diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb
index 9f10a93148c..588cced5781 100644
--- a/app/models/project_ci_cd_setting.rb
+++ b/app/models/project_ci_cd_setting.rb
@@ -1,5 +1,5 @@
class ProjectCiCdSetting < ActiveRecord::Base
- belongs_to :project
+ belongs_to :project, inverse_of: :ci_cd_settings
# The version of the schema that first introduced this model/table.
MINIMUM_SCHEMA_VERSION = 20180403035759
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index 8f8a5fbb2b0..a7d8ad93f38 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -91,7 +91,10 @@ module Ci
def builds_for_group_runner
hierarchy_groups = Gitlab::GroupHierarchy.new(runner.groups).base_and_descendants
projects = Project.where(namespace_id: hierarchy_groups)
- new_builds.where(project: projects.without_deleted.with_builds_enabled).order('created_at ASC')
+ .with_group_runners_enabled
+ .with_builds_enabled
+ .without_deleted
+ new_builds.where(project: projects).order('created_at ASC')
end
def running_builds_for_shared_runners