2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2014-09-15 03:57:02 -04:00
|
|
|
factory :group_member do
|
|
|
|
access_level { GroupMember::OWNER }
|
2020-09-09 02:08:55 -04:00
|
|
|
source { association(:group) }
|
2013-06-17 06:41:35 -04:00
|
|
|
user
|
2016-09-20 08:18:11 -04:00
|
|
|
|
2019-10-01 20:06:26 -04:00
|
|
|
trait(:guest) { access_level { GroupMember::GUEST } }
|
|
|
|
trait(:reporter) { access_level { GroupMember::REPORTER } }
|
|
|
|
trait(:developer) { access_level { GroupMember::DEVELOPER } }
|
|
|
|
trait(:maintainer) { access_level { GroupMember::MAINTAINER } }
|
|
|
|
trait(:owner) { access_level { GroupMember::OWNER } }
|
2018-09-20 13:02:36 -04:00
|
|
|
trait(:access_request) { requested_at { Time.now } }
|
2017-05-18 09:18:26 -04:00
|
|
|
|
|
|
|
trait(:invited) do
|
2019-10-01 20:06:26 -04:00
|
|
|
user_id { nil }
|
|
|
|
invite_token { 'xxx' }
|
2019-05-18 11:06:20 -04:00
|
|
|
sequence :invite_email do |n|
|
|
|
|
"email#{n}@email.com"
|
|
|
|
end
|
2017-05-18 09:18:26 -04:00
|
|
|
end
|
2019-07-17 22:09:30 -04:00
|
|
|
|
|
|
|
trait(:ldap) do
|
2019-10-01 20:06:26 -04:00
|
|
|
ldap { true }
|
2019-07-17 22:09:30 -04:00
|
|
|
end
|
2019-08-30 17:30:51 -04:00
|
|
|
|
|
|
|
trait :blocked do
|
|
|
|
after(:build) { |group_member, _| group_member.user.block! }
|
|
|
|
end
|
2020-09-10 14:08:54 -04:00
|
|
|
|
|
|
|
trait :minimal_access do
|
|
|
|
to_create { |instance| instance.save!(validate: false) }
|
|
|
|
|
|
|
|
access_level { GroupMember::MINIMAL_ACCESS }
|
|
|
|
end
|
2021-10-25 08:10:19 -04:00
|
|
|
|
2022-02-10 10:12:42 -05:00
|
|
|
trait :awaiting do
|
|
|
|
after(:create) do |member|
|
|
|
|
member.update!(state: ::Member::STATE_AWAITING)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :active do
|
|
|
|
after(:create) do |member|
|
|
|
|
member.update!(state: ::Member::STATE_ACTIVE)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-25 08:10:19 -04:00
|
|
|
transient do
|
|
|
|
tasks_to_be_done { [] }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |group_member, evaluator|
|
|
|
|
if evaluator.tasks_to_be_done.present?
|
|
|
|
build(:member_task,
|
|
|
|
member: group_member,
|
|
|
|
project: build(:project, namespace: group_member.source),
|
|
|
|
tasks_to_be_done: evaluator.tasks_to_be_done)
|
|
|
|
end
|
|
|
|
end
|
2013-06-17 06:07:16 -04:00
|
|
|
end
|
|
|
|
end
|