2020-04-19 12:47:19 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :user do
|
2020-04-20 14:03:57 -07:00
|
|
|
sequence(:screen_name) { |i| "#{Faker::Internet.username(specifier: 0..12, separators: %w[_])}#{i}" }
|
2020-04-19 12:47:19 -07:00
|
|
|
sequence(:email) { |i| "#{i}#{Faker::Internet.email}" }
|
2020-04-20 14:03:57 -07:00
|
|
|
password { 'P4s5w0rD' }
|
2020-04-19 12:47:19 -07:00
|
|
|
confirmed_at { Time.now.utc }
|
|
|
|
|
|
|
|
transient do
|
|
|
|
roles { [] }
|
2021-12-19 14:51:06 -08:00
|
|
|
profile { { display_name: Faker::Name.name } }
|
2020-04-19 12:47:19 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |user, evaluator|
|
|
|
|
evaluator.roles.each do |role|
|
|
|
|
user.add_role role
|
|
|
|
end
|
2021-12-19 14:51:06 -08:00
|
|
|
|
|
|
|
evaluator.profile.each do |key, value|
|
|
|
|
user.profile.public_send(:"#{key}=", value)
|
|
|
|
end
|
2020-04-19 12:47:19 -07:00
|
|
|
end
|
|
|
|
end
|
2021-12-19 14:51:06 -08:00
|
|
|
end
|