2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2017-01-20 06:25:53 -05:00
|
|
|
factory :group, class: Group, parent: :namespace do
|
2016-02-16 22:55:24 -05:00
|
|
|
sequence(:name) { |n| "group#{n}" }
|
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
|
|
|
type 'Group'
|
2017-01-20 06:25:53 -05:00
|
|
|
owner nil
|
2016-03-18 08:28:16 -04:00
|
|
|
|
2018-04-23 11:48:26 -04:00
|
|
|
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-03-18 08:28:16 -04:00
|
|
|
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
|
2016-11-11 07:51:50 -05:00
|
|
|
|
2017-05-03 11:25:31 -04:00
|
|
|
trait :with_avatar do
|
2018-02-01 14:24:59 -05:00
|
|
|
avatar { fixture_file_upload('spec/fixtures/dk.png') }
|
2017-05-03 11:25:31 -04:00
|
|
|
end
|
|
|
|
|
2016-11-11 07:51:50 -05:00
|
|
|
trait :access_requestable do
|
|
|
|
request_access_enabled true
|
|
|
|
end
|
2016-12-07 12:16:17 -05:00
|
|
|
|
|
|
|
trait :nested do
|
|
|
|
parent factory: :group
|
|
|
|
end
|
2016-02-16 22:55:24 -05:00
|
|
|
end
|
|
|
|
end
|