gitlab-org--gitlab-foss/spec/factories/groups.rb

56 lines
1.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
FactoryBot.define do
factory :group, class: 'Group', parent: :namespace do
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
type { 'Group' }
owner { nil }
project_creation_level { ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS }
2016-03-18 12:28:16 +00:00
after(:create) do |group|
if group.owner
# We could remove this after we have proper constraint:
# https://gitlab.com/gitlab-org/gitlab-foss/issues/43292
raise "Don't set owner for groups, use `group.add_owner(user)` instead"
end
end
2016-03-18 12:28:16 +00:00
trait :public do
visibility_level { Gitlab::VisibilityLevel::PUBLIC }
2016-03-18 12:28:16 +00:00
end
trait :internal do
visibility_level {Gitlab::VisibilityLevel::INTERNAL }
2016-03-18 12:28:16 +00:00
end
trait :private do
visibility_level { Gitlab::VisibilityLevel::PRIVATE }
2016-03-18 12:28:16 +00:00
end
trait :with_avatar do
2018-02-01 19:24:59 +00:00
avatar { fixture_file_upload('spec/fixtures/dk.png') }
end
trait :request_access_disabled do
request_access_enabled { false }
end
trait :nested do
parent factory: :group
end
trait :auto_devops_enabled do
auto_devops_enabled { true }
end
trait :auto_devops_disabled do
auto_devops_enabled { false }
end
trait :owner_subgroup_creation_only do
subgroup_creation_level { ::Gitlab::Access::OWNER_SUBGROUP_ACCESS }
end
end
end