2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2016-02-16 22:55:24 -05:00
|
|
|
factory :project_member do
|
|
|
|
user
|
2020-09-09 02:08:55 -04:00
|
|
|
source { association(:project) }
|
2022-09-15 17:12:27 -04:00
|
|
|
member_namespace_id { source.id }
|
2018-07-11 10:36:08 -04:00
|
|
|
maintainer
|
2016-03-06 16:53:22 -05:00
|
|
|
|
2022-06-14 08:08:53 -04:00
|
|
|
trait(:guest) { access_level { ProjectMember::GUEST } }
|
|
|
|
trait(:reporter) { access_level { ProjectMember::REPORTER } }
|
2019-10-01 20:06:26 -04:00
|
|
|
trait(:developer) { access_level { ProjectMember::DEVELOPER } }
|
|
|
|
trait(:maintainer) { access_level { ProjectMember::MAINTAINER } }
|
2022-06-14 08:08:53 -04:00
|
|
|
trait(:owner) { access_level { ProjectMember::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' }
|
2021-01-06 04:10:31 -05:00
|
|
|
sequence :invite_email do |n|
|
|
|
|
"email#{n}@email.com"
|
|
|
|
end
|
2017-05-18 09:18:26 -04:00
|
|
|
end
|
2019-08-30 17:30:51 -04:00
|
|
|
|
|
|
|
trait :blocked do
|
|
|
|
after(:build) { |project_member, _| project_member.user.block! }
|
|
|
|
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 |project_member, evaluator|
|
|
|
|
if evaluator.tasks_to_be_done.present?
|
|
|
|
build(:member_task, member: project_member, project: project_member.source, tasks_to_be_done: evaluator.tasks_to_be_done)
|
|
|
|
end
|
|
|
|
end
|
2016-02-16 22:55:24 -05:00
|
|
|
end
|
|
|
|
end
|