8b4df986bf
Addresses: #402 - migrations to split roles and other attributes from users table - make changes in code to accommodate this change Co-authored-by: Sojan Jose <sojan@pepalo.com> Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
32 lines
836 B
Ruby
32 lines
836 B
Ruby
# frozen_string_literal: true
|
|
|
|
FactoryBot.define do
|
|
factory :user do
|
|
transient do
|
|
skip_confirmation { true }
|
|
role { 'agent' }
|
|
account { nil }
|
|
inviter { nil }
|
|
end
|
|
|
|
provider { 'email' }
|
|
uid { SecureRandom.uuid }
|
|
name { Faker::Name.name }
|
|
nickname { Faker::Name.first_name }
|
|
email { nickname + '@example.com' }
|
|
password { 'password' }
|
|
|
|
after(:build) do |user, evaluator|
|
|
user.skip_confirmation! if evaluator.skip_confirmation
|
|
create(:account_user, user: user, account: evaluator.account, role: evaluator.role, inviter: evaluator.inviter) if evaluator.account
|
|
end
|
|
|
|
trait :with_avatar do
|
|
avatar { Rack::Test::UploadedFile.new('spec/assets/avatar.png', 'image/png') }
|
|
end
|
|
|
|
trait :administrator do
|
|
role { 'administrator' }
|
|
end
|
|
end
|
|
end
|