Commit 8d813986 authored by Dylan Griffith's avatar Dylan Griffith

Rename `runner.belonging_to_group(project.id) ->...

Rename `runner.belonging_to_group(project.id) -> runner.belonging_to_parent_group_of_project(project.id)`
parent 3c3e1443
...@@ -79,7 +79,7 @@ module Projects ...@@ -79,7 +79,7 @@ module Projects
@shared_runners_count = @shared_runners.count(:all) @shared_runners_count = @shared_runners.count(:all)
@group_runners = ::Ci::Runner.belonging_to_group(@project.id) @group_runners = ::Ci::Runner.belonging_to_parent_group_of_project(@project.id)
end end
def define_secret_variables def define_secret_variables
......
...@@ -34,7 +34,7 @@ module Ci ...@@ -34,7 +34,7 @@ module Ci
scope :belonging_to_any_project, -> { joins(:runner_projects) } scope :belonging_to_any_project, -> { joins(:runner_projects) }
scope :belonging_to_group, -> (project_id) { scope :belonging_to_parent_group_of_project, -> (project_id) {
project_groups = ::Group.joins(:projects).where(projects: { id: project_id }) project_groups = ::Group.joins(:projects).where(projects: { id: project_id })
hierarchy_groups = Gitlab::GroupHierarchy.new(project_groups).base_and_ancestors hierarchy_groups = Gitlab::GroupHierarchy.new(project_groups).base_and_ancestors
...@@ -42,7 +42,7 @@ module Ci ...@@ -42,7 +42,7 @@ module Ci
} }
scope :owned_or_shared, -> (project_id) do scope :owned_or_shared, -> (project_id) do
union = Gitlab::SQL::Union.new([belonging_to_project(project_id), belonging_to_group(project_id), shared]) union = Gitlab::SQL::Union.new([belonging_to_project(project_id), belonging_to_parent_group_of_project(project_id), shared])
from("(#{union.to_sql}) ci_runners") from("(#{union.to_sql}) ci_runners")
end end
......
...@@ -1297,7 +1297,7 @@ class Project < ActiveRecord::Base ...@@ -1297,7 +1297,7 @@ class Project < ActiveRecord::Base
end end
def group_runners def group_runners
@group_runners ||= group_runners_enabled? ? Ci::Runner.belonging_to_group(self.id) : Ci::Runner.none @group_runners ||= group_runners_enabled? ? Ci::Runner.belonging_to_parent_group_of_project(self.id) : Ci::Runner.none
end end
def any_runners?(&block) def any_runners?(&block)
......
...@@ -4,7 +4,7 @@ module Ci ...@@ -4,7 +4,7 @@ module Ci
tick_for(build, build.project.runners) tick_for(build, build.project.runners)
if build.project.group_runners_enabled? if build.project.group_runners_enabled?
tick_for(build, Ci::Runner.belonging_to_group(build.project_id)) tick_for(build, Ci::Runner.belonging_to_parent_group_of_project(build.project_id))
end end
if build.project.shared_runners_enabled? if build.project.shared_runners_enabled?
......
...@@ -151,7 +151,7 @@ describe Ci::Runner do ...@@ -151,7 +151,7 @@ describe Ci::Runner do
end end
end end
describe '.belonging_to_group' do describe '.belonging_to_parent_group_of_project' do
it 'returns the specific group runner' do it 'returns the specific group runner' do
# own # own
specific_group = create :group specific_group = create :group
...@@ -163,7 +163,7 @@ describe Ci::Runner do ...@@ -163,7 +163,7 @@ describe Ci::Runner do
create :project, group: other_group create :project, group: other_group
create :ci_runner, :specific, groups: [other_group] create :ci_runner, :specific, groups: [other_group]
expect(described_class.belonging_to_group(specific_project.id)).to eq [specific_runner] expect(described_class.belonging_to_parent_group_of_project(specific_project.id)).to eq [specific_runner]
end end
it 'returns the group runner from a parent group', :nested_groups do it 'returns the group runner from a parent group', :nested_groups do
...@@ -172,7 +172,7 @@ describe Ci::Runner do ...@@ -172,7 +172,7 @@ describe Ci::Runner do
project = create :project, group: group project = create :project, group: group
runner = create :ci_runner, :specific, groups: [parent_group] runner = create :ci_runner, :specific, groups: [parent_group]
expect(described_class.belonging_to_group(project.id)).to eq [runner] expect(described_class.belonging_to_parent_group_of_project(project.id)).to eq [runner]
end end
end end
......
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