debian-mirror-gitlab/spec/factories/namespaces.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2022-01-26 12:08:38 +05:30
# This factory is called :namespace but actually maps (and always has) to User type
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74152#note_730034103 for context
factory :namespace, class: 'Namespaces::UserNamespace' do
2016-06-02 11:05:42 +05:30
sequence(:name) { |n| "namespace#{n}" }
2022-01-26 12:08:38 +05:30
type { Namespaces::UserNamespace.sti_name }
2016-06-02 11:05:42 +05:30
path { name.downcase.gsub(/\s/, '_') }
2018-10-15 14:42:47 +05:30
2021-06-08 01:23:25 +05:30
owner { association(:user, strategy: :build, namespace: instance, username: path) }
2019-09-30 21:07:59 +05:30
2022-03-02 08:16:31 +05:30
after(:create) do |namespace, evaluator|
# simulating ::Namespaces::ProcessSyncEventsWorker because most tests don't run Sidekiq inline
# Note: we need to get refreshed `traversal_ids` it is updated via SQL query
# in `Namespaces::Traversal::Linear#sync_traversal_ids` (see the NOTE in that method).
# We cannot use `.reload` because it cleans other on-the-fly attributes.
namespace.create_ci_namespace_mirror!(traversal_ids: Namespace.find(namespace.id).traversal_ids) unless namespace.ci_namespace_mirror
end
2019-09-30 21:07:59 +05:30
trait :with_aggregation_schedule do
2021-04-17 20:07:23 +05:30
after(:create) do |namespace|
create(:namespace_aggregation_schedules, namespace: namespace)
end
2019-09-30 21:07:59 +05:30
end
trait :with_root_storage_statistics do
2021-04-17 20:07:23 +05:30
after(:create) do |namespace|
create(:namespace_root_storage_statistics, namespace: namespace)
end
2019-09-30 21:07:59 +05:30
end
2020-07-28 23:09:34 +05:30
2020-10-24 23:57:45 +05:30
trait :with_namespace_settings do
2021-04-17 20:07:23 +05:30
after(:create) do |namespace|
create(:namespace_settings, namespace: namespace)
2020-07-28 23:09:34 +05:30
end
end
2021-01-03 14:25:43 +05:30
trait :shared_runners_disabled do
shared_runners_enabled { false }
end
trait :allow_descendants_override_disabled_shared_runners do
allow_descendants_override_disabled_shared_runners { true }
end
2016-06-02 11:05:42 +05:30
end
end