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

56 lines
1.3 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
2017-08-17 22:00:37 +05:30
factory :group, class: Group, parent: :namespace do
2016-06-02 11:05:42 +05:30
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
type 'Group'
2017-08-17 22:00:37 +05:30
owner nil
2019-07-07 11:18:12 +05:30
project_creation_level ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS
2016-06-02 11:05:42 +05:30
2018-10-15 14:42:47 +05:30
after(:create) do |group|
if group.owner
# We could remove this after we have proper constraint:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/43292
raise "Don't set owner for groups, use `group.add_owner(user)` instead"
end
end
2016-06-02 11:05:42 +05:30
trait :public do
visibility_level Gitlab::VisibilityLevel::PUBLIC
end
trait :internal do
visibility_level Gitlab::VisibilityLevel::INTERNAL
end
trait :private do
visibility_level Gitlab::VisibilityLevel::PRIVATE
end
2017-08-17 22:00:37 +05:30
trait :with_avatar do
2018-03-17 18:26:18 +05:30
avatar { fixture_file_upload('spec/fixtures/dk.png') }
2017-08-17 22:00:37 +05:30
end
trait :access_requestable do
request_access_enabled true
end
trait :nested do
parent factory: :group
end
2019-07-07 11:18:12 +05:30
trait :auto_devops_enabled do
auto_devops_enabled true
end
trait :auto_devops_disabled do
auto_devops_enabled false
end
2019-10-12 21:52:04 +05:30
trait :owner_subgroup_creation_only do
subgroup_creation_level ::Gitlab::Access::OWNER_SUBGROUP_ACCESS
end
2016-06-02 11:05:42 +05:30
end
end