Update administrateur factory

This commit is contained in:
simon lehericey 2019-08-09 10:39:14 +02:00
parent 4142acf8d3
commit 27c81c1992

View file

@ -2,18 +2,20 @@ FactoryBot.define do
sequence(:administrateur_email) { |n| "admin#{n}@admin.com" }
factory :administrateur do
email { generate(:administrateur_email) }
password { 'mon chien aime les bananes' }
transient do
user { nil }
password { 'mon chien aime les bananes' }
end
after(:create) do |admin, evaluator|
after(:create) do |administrateur, evaluator|
if evaluator.user.present?
create(:instructeur, email: admin.email, password: admin.password, user: evaluator.user)
user = evaluator.user
else
create(:instructeur, email: admin.email, password: admin.password)
user = create(:user, email: administrateur.email, password: evaluator.password, administrateur: administrateur)
end
create(:instructeur, email: administrateur.email, user: user)
end
end