2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2017-06-01 17:44:56 +02:00
|
|
|
sequence(:administrateur_email) { |n| "admin#{n}@admin.com" }
|
2015-10-26 15:54:20 +01:00
|
|
|
factory :administrateur do
|
2021-10-25 15:50:48 +02:00
|
|
|
user { association :user, email: email, password: password }
|
|
|
|
|
2019-08-08 16:55:51 +02:00
|
|
|
transient do
|
2020-02-03 11:09:54 +01:00
|
|
|
email { generate(:administrateur_email) }
|
2020-09-18 09:57:26 +02:00
|
|
|
password { 'Mon [hien 4im3 {es banane$' }
|
2021-10-25 15:50:48 +02:00
|
|
|
instructeur { build(:instructeur, user: user) }
|
2019-08-08 16:55:51 +02:00
|
|
|
end
|
|
|
|
|
2021-10-25 15:50:48 +02:00
|
|
|
after(:build) do |administrateur, evaluator|
|
|
|
|
if administrateur.user
|
|
|
|
administrateur.user.instructeur = evaluator.instructeur
|
|
|
|
end
|
2019-01-07 15:11:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-24 15:53:57 +02:00
|
|
|
trait :with_api_token do
|
|
|
|
after(:create) do |admin|
|
2022-11-30 10:06:33 +01:00
|
|
|
APIToken.generate(admin)
|
2018-08-24 15:53:57 +02:00
|
|
|
end
|
|
|
|
end
|
2019-01-03 17:42:43 +01:00
|
|
|
|
|
|
|
trait :with_procedure do
|
|
|
|
after(:create) do |admin|
|
2019-02-26 16:57:04 +01:00
|
|
|
create(:simple_procedure, administrateur: admin)
|
|
|
|
admin.reload
|
2019-01-03 17:42:43 +01:00
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|