Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
4d3b1c506f
commit
0712a75cc0
8 changed files with 41 additions and 20 deletions
|
@ -439,10 +439,8 @@ module Ci
|
|||
end
|
||||
|
||||
def no_groups
|
||||
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') do
|
||||
if groups.any?
|
||||
errors.add(:runner, 'cannot have groups assigned')
|
||||
end
|
||||
if runner_namespaces.any?
|
||||
errors.add(:runner, 'cannot have groups assigned')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -453,10 +451,8 @@ module Ci
|
|||
end
|
||||
|
||||
def exactly_one_group
|
||||
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') do
|
||||
unless groups.one?
|
||||
errors.add(:runner, 'needs to be assigned to exactly one group')
|
||||
end
|
||||
unless runner_namespaces.one?
|
||||
errors.add(:runner, 'needs to be assigned to exactly one group')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ module Clusters
|
|||
}
|
||||
|
||||
if cluster.group_type?
|
||||
attributes[:groups] = [group]
|
||||
attributes[:runner_namespaces] = [::Ci::RunnerNamespace.new(namespace: group)]
|
||||
elsif cluster.project_type?
|
||||
attributes[:runner_projects] = [::Ci::RunnerProject.new(project: project)]
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ module Sidebars
|
|||
end
|
||||
|
||||
def dependency_proxy_menu_item
|
||||
unless context.group.dependency_proxy_feature_available?
|
||||
unless can?(context.current_user, :read_dependency_proxy, context.group)
|
||||
return ::Sidebars::NilMenuItem.new(item_id: :dependency_proxy)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,14 @@
|
|||
|
||||
FactoryBot.define do
|
||||
factory :ci_runner_namespace, class: 'Ci::RunnerNamespace' do
|
||||
runner factory: [:ci_runner, :group]
|
||||
group
|
||||
|
||||
after(:build) do |runner_namespace, evaluator|
|
||||
unless runner_namespace.runner.present?
|
||||
runner_namespace.runner = build(
|
||||
:ci_runner, :group, runner_namespaces: [runner_namespace]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,7 @@ FactoryBot.define do
|
|||
runner_type { :instance_type }
|
||||
|
||||
transient do
|
||||
groups { [] }
|
||||
projects { [] }
|
||||
end
|
||||
|
||||
|
@ -18,6 +19,10 @@ FactoryBot.define do
|
|||
evaluator.projects.each do |proj|
|
||||
runner.runner_projects << build(:ci_runner_project, project: proj)
|
||||
end
|
||||
|
||||
evaluator.groups.each do |group|
|
||||
runner.runner_namespaces << build(:ci_runner_namespace, namespace: group)
|
||||
end
|
||||
end
|
||||
|
||||
trait :online do
|
||||
|
@ -32,7 +37,9 @@ FactoryBot.define do
|
|||
runner_type { :group_type }
|
||||
|
||||
after(:build) do |runner, evaluator|
|
||||
runner.groups << build(:group) if runner.groups.empty?
|
||||
if runner.runner_namespaces.empty?
|
||||
runner.runner_namespaces << build(:ci_runner_namespace)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -137,16 +137,27 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
|
|||
stub_config(dependency_proxy: { enabled: dependency_enabled })
|
||||
end
|
||||
|
||||
context 'when config dependency_proxy is enabled' do
|
||||
let(:dependency_enabled) { true }
|
||||
context 'when user can read dependency proxy' do
|
||||
context 'when config dependency_proxy is enabled' do
|
||||
let(:dependency_enabled) { true }
|
||||
|
||||
it 'the menu item is added to list of menu items' do
|
||||
is_expected.not_to be_nil
|
||||
it 'the menu item is added to list of menu items' do
|
||||
is_expected.not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when config dependency_proxy is not enabled' do
|
||||
let(:dependency_enabled) { false }
|
||||
|
||||
it 'the menu item is not added to list of menu items' do
|
||||
is_expected.to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when config dependency_proxy is not enabled' do
|
||||
let(:dependency_enabled) { false }
|
||||
context 'when user cannot read dependency proxy' do
|
||||
let(:user) { nil }
|
||||
let(:dependency_enabled) { true }
|
||||
|
||||
it 'the menu item is not added to list of menu items' do
|
||||
is_expected.to be_nil
|
||||
|
|
|
@ -44,7 +44,7 @@ RSpec.describe Ci::Runner do
|
|||
let(:runner) { create(:ci_runner, :group, groups: [group]) }
|
||||
|
||||
it 'disallows assigning group if already assigned to a group' do
|
||||
runner.groups << build(:group)
|
||||
runner.runner_namespaces << build(:ci_runner_namespace)
|
||||
|
||||
expect(runner).not_to be_valid
|
||||
expect(runner.errors.full_messages).to include('Runner needs to be assigned to exactly one group')
|
||||
|
|
|
@ -112,7 +112,7 @@ RSpec.describe Clusters::Applications::Runner do
|
|||
subject
|
||||
|
||||
expect(runner).to be_group_type
|
||||
expect(runner.groups).to eq [group]
|
||||
expect(runner.runner_namespaces.pluck(:namespace_id)).to match_array [group.id]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue