Simplify instructeur and administrateur factory
This commit is contained in:
parent
c1a622efa1
commit
e0e29d741f
2 changed files with 4 additions and 17 deletions
|
@ -4,18 +4,11 @@ FactoryBot.define do
|
|||
email { generate(:administrateur_email) }
|
||||
|
||||
transient do
|
||||
user { nil }
|
||||
password { 'mon chien aime les bananes' }
|
||||
end
|
||||
|
||||
after(:create) do |administrateur, evaluator|
|
||||
if evaluator.user.present?
|
||||
user = evaluator.user
|
||||
else
|
||||
user = create(:user, email: administrateur.email, password: evaluator.password, administrateur: administrateur)
|
||||
end
|
||||
|
||||
create(:instructeur, email: administrateur.email, user: user)
|
||||
initialize_with do
|
||||
User.create_or_promote_to_administrateur(email, password).administrateur
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,14 +8,8 @@ FactoryBot.define 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)
|
||||
initialize_with do
|
||||
User.create_or_promote_to_instructeur(email, password).instructeur
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue