2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2019-10-21 11:45:03 +02:00
|
|
|
sequence(:expert_email) { |n| "expert#{n}@expert.com" }
|
|
|
|
|
2017-04-27 12:17:50 +02:00
|
|
|
factory :avis do
|
2019-10-21 11:45:03 +02:00
|
|
|
email { generate(:expert_email) }
|
2018-09-04 16:46:48 +02:00
|
|
|
introduction { 'Bonjour, merci de me donner votre avis sur ce dossier' }
|
2019-10-21 11:45:03 +02:00
|
|
|
confidentiel { false }
|
2017-04-27 12:17:50 +02:00
|
|
|
|
2019-10-21 11:45:03 +02:00
|
|
|
association :dossier
|
|
|
|
association :claimant, factory: :instructeur
|
2019-04-04 10:13:24 +02:00
|
|
|
|
2021-03-23 12:25:57 +01:00
|
|
|
after(:build) do |avis, _evaluator|
|
|
|
|
avis.experts_procedure ||= build(:experts_procedure, procedure: avis.dossier.procedure)
|
|
|
|
end
|
|
|
|
|
2023-03-28 16:51:35 +02:00
|
|
|
trait :confidentiel do
|
|
|
|
confidentiel { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :not_confidentiel do
|
|
|
|
confidentiel { false }
|
|
|
|
end
|
|
|
|
|
2020-07-20 16:32:22 +02:00
|
|
|
trait :with_instructeur do
|
|
|
|
email { nil }
|
|
|
|
instructeur { association :instructeur, email: generate(:expert_email) }
|
|
|
|
end
|
|
|
|
|
2019-04-04 10:13:24 +02:00
|
|
|
trait :with_answer do
|
2019-10-21 11:45:03 +02:00
|
|
|
answer { "Mon avis se décompose en deux points :\n- La demande semble pertinente\n- Le demandeur remplit les conditions." }
|
2019-04-04 10:13:24 +02:00
|
|
|
end
|
2023-05-15 12:54:01 +02:00
|
|
|
|
|
|
|
trait :with_introduction do
|
|
|
|
introduction_file { Rack::Test::UploadedFile.new('spec/fixtures/files/white.png', 'image/png') }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_piece_justificative do
|
|
|
|
piece_justificative_file { Rack::Test::UploadedFile.new('spec/fixtures/files/white.png', 'image/png') }
|
|
|
|
end
|
2017-04-27 12:17:50 +02:00
|
|
|
end
|
|
|
|
end
|