summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-09-25 16:46:03 +0200
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-02-28 09:50:48 +0100
commitfc0679c3369a6b683e6ec89c98fb44589c854cb8 (patch)
tree90e1eabfa7065f1db17bcf5aaddaf5f57724882a
parent95e487eaa01464fb313480fb5cde681c1e7941b6 (diff)
downloadgitlab-ce-fc0679c3369a6b683e6ec89c98fb44589c854cb8.tar.gz
exclude group runners on projects that disabled it
-rw-r--r--app/models/ci/runner.rb9
-rw-r--r--spec/models/ci/runner_spec.rb8
2 files changed, 14 insertions, 3 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index 3d4927efad0..45d805fceee 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -34,13 +34,16 @@ module Ci
%{
INNER JOIN ci_runner_groups ON ci_runner_groups.runner_id = ci_runners.id
INNER JOIN namespaces ON namespaces.id = ci_runner_groups.group_id
- INNER JOIN projects group_projects ON group_projects.namespace_id = namespaces.id
+ INNER JOIN projects ON projects.namespace_id = namespaces.id
}
).where(
%{
- group_projects.id = :project_id
+ projects.id = :project_id
+ AND
+ projects.group_runners_enabled = :true
},
- project_id: project_id
+ project_id: project_id,
+ true: true
)
shared_runners = where(is_shared: true)
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index b9aafa63493..933bd6e5f23 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -83,6 +83,14 @@ describe Ci::Runner do
expect(described_class.owned_or_shared(specific_project.id)).to eq [specific_runner]
end
+ it 'does not return the group runner if the project has group runners disabled' do
+ specific_group = create :group
+ specific_project = create :project, group: specific_group, group_runners_enabled: false
+ create :ci_runner, :specific, groups: [specific_group]
+
+ expect(described_class.owned_or_shared(specific_project.id)).to be_empty
+ end
+
it 'returns the shared group runner' do
group = create :group
runner = create :ci_runner, :shared, groups: [group]