2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2016-06-02 11:05:42 +05:30
|
|
|
factory :namespace do
|
|
|
|
sequence(:name) { |n| "namespace#{n}" }
|
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
# This is a workaround to avoid the user creating another namespace via
|
|
|
|
# User#ensure_namespace_correct. We should try to remove it and then
|
|
|
|
# we could remove this workaround
|
|
|
|
association :owner, factory: :user, strategy: :build
|
|
|
|
before(:create) do |namespace|
|
|
|
|
owner = namespace.owner
|
|
|
|
|
|
|
|
if owner
|
|
|
|
# We're changing the username here because we want to keep our path,
|
|
|
|
# and User#ensure_namespace_correct would change the path based on
|
|
|
|
# username, so we're forced to do this otherwise we'll need to change
|
|
|
|
# a lot of existing tests.
|
|
|
|
owner.username = namespace.path
|
|
|
|
owner.namespace = namespace
|
|
|
|
end
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
trait :with_aggregation_schedule do
|
|
|
|
association :aggregation_schedule, factory: :namespace_aggregation_schedules
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_root_storage_statistics do
|
|
|
|
association :root_storage_statistics, factory: :namespace_root_storage_statistics
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|