2019-10-12 18:08:41 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :user do
|
2019-10-14 08:54:58 +00:00
|
|
|
transient do
|
|
|
|
skip_confirmation { true }
|
2020-03-07 06:48:16 +00:00
|
|
|
role { 'agent' }
|
|
|
|
account { nil }
|
|
|
|
inviter { nil }
|
2019-10-14 08:54:58 +00:00
|
|
|
end
|
|
|
|
|
2019-10-12 18:08:41 +00:00
|
|
|
provider { 'email' }
|
|
|
|
uid { SecureRandom.uuid }
|
2019-10-16 21:48:07 +00:00
|
|
|
name { Faker::Name.name }
|
2020-07-20 12:58:14 +00:00
|
|
|
display_name { Faker::Name.first_name }
|
|
|
|
email { display_name + "@#{SecureRandom.uuid}.com" }
|
2021-06-07 11:56:08 +00:00
|
|
|
password { 'Password1!' }
|
2019-10-14 08:54:58 +00:00
|
|
|
|
|
|
|
after(:build) do |user, evaluator|
|
|
|
|
user.skip_confirmation! if evaluator.skip_confirmation
|
2020-03-07 06:48:16 +00:00
|
|
|
create(:account_user, user: user, account: evaluator.account, role: evaluator.role, inviter: evaluator.inviter) if evaluator.account
|
2019-10-14 08:54:58 +00:00
|
|
|
end
|
2019-12-10 04:59:35 +00:00
|
|
|
|
|
|
|
trait :with_avatar do
|
|
|
|
avatar { Rack::Test::UploadedFile.new('spec/assets/avatar.png', 'image/png') }
|
|
|
|
end
|
2019-12-27 19:57:59 +00:00
|
|
|
|
|
|
|
trait :administrator do
|
|
|
|
role { 'administrator' }
|
|
|
|
end
|
2019-10-12 18:08:41 +00:00
|
|
|
end
|
|
|
|
end
|