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 }
|
2019-10-20 08:47:26 +00:00
|
|
|
nickname { Faker::Name.first_name }
|
2019-10-14 08:54:58 +00:00
|
|
|
email { nickname + '@example.com' }
|
2019-10-20 08:47:26 +00:00
|
|
|
password { 'password' }
|
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
|