Update administrateur factory
This commit is contained in:
parent
4142acf8d3
commit
27c81c1992
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue