2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2019-08-08 16:55:51 +02:00
|
|
|
sequence(:instructeur_email) { |n| "inst#{n}@inst.com" }
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
factory :instructeur do
|
|
|
|
email { generate(:instructeur_email) }
|
2019-08-08 16:55:51 +02:00
|
|
|
|
|
|
|
transient do
|
|
|
|
password { 'somethingverycomplated!' }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |instructeur, evaluator|
|
|
|
|
if evaluator.user.present?
|
|
|
|
user = evaluator.user
|
|
|
|
else
|
|
|
|
user = create(:user, email: instructeur.email, password: evaluator.password)
|
|
|
|
end
|
|
|
|
|
|
|
|
instructeur.update!(user: user)
|
|
|
|
end
|
2015-09-22 10:15:12 +02:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|