exclude group runners on projects that disabled it

This commit is contained in:
Alexis Reigel 2017-09-25 16:46:03 +02:00 committed by Alexis Reigel
parent 677291b6a7
commit 81c0c57acd
No known key found for this signature in database
GPG key ID: 55ADA7C7B683B329
2 changed files with 14 additions and 3 deletions

View file

@ -35,13 +35,16 @@ module Ci
%{ %{
INNER JOIN ci_runner_groups ON ci_runner_groups.runner_id = ci_runners.id 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 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( ).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) shared_runners = where(is_shared: true)

View file

@ -83,6 +83,14 @@ describe Ci::Runner do
expect(described_class.owned_or_shared(specific_project.id)).to eq [specific_runner] expect(described_class.owned_or_shared(specific_project.id)).to eq [specific_runner]
end 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 it 'returns the shared group runner' do
group = create :group group = create :group
runner = create :ci_runner, :shared, groups: [group] runner = create :ci_runner, :shared, groups: [group]