Commit 897632dc authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'pedropombeiro/351758/rest-fix-project-runners-scope' into 'master'

REST: Fix scope of GET /projects/:id/runners endpoint

See merge request gitlab-org/gitlab!79733
parents d8dccea0 b5ded2bc
...@@ -157,9 +157,9 @@ module Ci ...@@ -157,9 +157,9 @@ module Ci
from_union( from_union(
[ [
belonging_to_project(project_id), belonging_to_project(project_id),
belonging_to_parent_group_of_project(project_id), project.group_runners_enabled? ? belonging_to_parent_group_of_project(project_id) : nil,
project.shared_runners project.shared_runners
], ].compact,
remove_duplicates: false remove_duplicates: false
) )
end end
......
...@@ -302,22 +302,40 @@ RSpec.describe Ci::Runner do ...@@ -302,22 +302,40 @@ RSpec.describe Ci::Runner do
context 'with instance runners sharing disabled' do context 'with instance runners sharing disabled' do
# group specific # group specific
let_it_be(:group) { create(:group, shared_runners_enabled: false) } let_it_be(:group) { create(:group, shared_runners_enabled: false) }
let_it_be(:project) { create(:project, group: group, shared_runners_enabled: false) }
let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group]) } let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let(:group_runners_enabled) { true }
let(:project) { create(:project, group: group, shared_runners_enabled: false) }
# project specific # project specific
let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project]) } let(:project_runner) { create(:ci_runner, :project, projects: [project]) }
# globally shared # globally shared
let_it_be(:shared_runner) { create(:ci_runner, :instance) } let_it_be(:shared_runner) { create(:ci_runner, :instance) }
before do
project.update!(group_runners_enabled: group_runners_enabled)
end
describe '.owned_or_instance_wide' do describe '.owned_or_instance_wide' do
subject { described_class.owned_or_instance_wide(project.id) } subject { described_class.owned_or_instance_wide(project.id) }
context 'with group runners disabled' do
let(:group_runners_enabled) { false }
it 'returns only the project specific runner' do
is_expected.to contain_exactly(project_runner)
end
end
context 'with group runners enabled' do
let(:group_runners_enabled) { true }
it 'returns a project specific and a group specific runner' do it 'returns a project specific and a group specific runner' do
is_expected.to contain_exactly(group_runner, project_runner) is_expected.to contain_exactly(group_runner, project_runner)
end end
end end
end
describe '.group_or_instance_wide' do describe '.group_or_instance_wide' do
subject { described_class.group_or_instance_wide(group) } subject { described_class.group_or_instance_wide(group) }
......
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