2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2016-06-09 12:08:18 +02:00
|
|
|
factory :champ do
|
2020-07-20 17:18:44 +02:00
|
|
|
add_attribute(:private) { false }
|
2017-07-11 16:50:29 +02:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
dossier { association :dossier }
|
|
|
|
type_de_champ { association :type_de_champ, procedure: dossier.procedure }
|
2017-11-21 17:20:52 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
trait :private do
|
|
|
|
add_attribute(:private) { true }
|
2018-05-11 14:59:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_piece_justificative_file do
|
2020-07-20 17:18:44 +02:00
|
|
|
after(:build) do |champ, _evaluator|
|
2018-05-11 14:59:20 +02:00
|
|
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
|
|
|
end
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_text, class: 'Champs::TextChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_text, procedure: dossier.procedure }
|
|
|
|
value { 'text' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_textarea, class: 'Champs::TextareaChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_textarea, procedure: dossier.procedure }
|
|
|
|
value { 'textarea' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_date, class: 'Champs::DateChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_date, procedure: dossier.procedure }
|
|
|
|
value { '2019-07-10' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_datetime, class: 'Champs::DatetimeChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_datetime, procedure: dossier.procedure }
|
|
|
|
value { '15/09/1962 15:35' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_number, class: 'Champs::NumberChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_number, procedure: dossier.procedure }
|
|
|
|
value { '42' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_decimal_number, class: 'Champs::DecimalNumberChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_decimal_number, procedure: dossier.procedure }
|
|
|
|
value { '42.1' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_integer_number, class: 'Champs::IntegerNumberChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_integer_number, procedure: dossier.procedure }
|
|
|
|
value { '42' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_checkbox, class: 'Champs::CheckboxChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_checkbox, procedure: dossier.procedure }
|
|
|
|
value { 'on' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_civilite, class: 'Champs::CiviliteChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_civilite, procedure: dossier.procedure }
|
|
|
|
value { 'M.' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_email, class: 'Champs::EmailChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_email, procedure: dossier.procedure }
|
|
|
|
value { 'yoda@beta.gouv.fr' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_phone, class: 'Champs::PhoneChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_phone, procedure: dossier.procedure }
|
|
|
|
value { '0666666666' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_address, class: 'Champs::AddressChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_address, procedure: dossier.procedure }
|
|
|
|
value { '2 rue des Démarches' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_yes_no, class: 'Champs::YesNoChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_yes_no, procedure: dossier.procedure }
|
|
|
|
value { 'true' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_drop_down_list, class: 'Champs::DropDownListChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_drop_down_list, procedure: dossier.procedure }
|
|
|
|
value { 'choix 1' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_multiple_drop_down_list, class: 'Champs::MultipleDropDownListChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_multiple_drop_down_list, procedure: dossier.procedure }
|
|
|
|
value { '["choix 1", "choix 2"]' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_linked_drop_down_list, class: 'Champs::LinkedDropDownListChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_linked_drop_down_list, procedure: dossier.procedure }
|
|
|
|
value { '["categorie 1", "choix 1"]' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_pays, class: 'Champs::PaysChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_pays, procedure: dossier.procedure }
|
|
|
|
value { 'France' }
|
|
|
|
end
|
2020-01-14 18:46:07 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_regions, class: 'Champs::RegionChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_regions, procedure: dossier.procedure }
|
|
|
|
value { 'Guadeloupe' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_departements, class: 'Champs::DepartementChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_departements, procedure: dossier.procedure }
|
|
|
|
value { '971 - Guadeloupe' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_communes, class: 'Champs::CommuneChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_communes, procedure: dossier.procedure }
|
|
|
|
value { 'Paris' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_engagement, class: 'Champs::EngagementChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_engagement, procedure: dossier.procedure }
|
|
|
|
value { 'true' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_header_section, class: 'Champs::HeaderSectionChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_header_section, procedure: dossier.procedure }
|
|
|
|
value { 'une section' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_explication, class: 'Champs::ExplicationChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_explication, procedure: dossier.procedure }
|
|
|
|
value { '' }
|
2018-11-13 18:48:04 +01:00
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_dossier_link, class: 'Champs::DossierLinkChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_dossier_link, procedure: dossier.procedure }
|
|
|
|
value { create(:dossier).id }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_piece_justificative, procedure: dossier.procedure }
|
2018-12-18 11:17:52 +01:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
after(:build) do |champ, _evaluator|
|
|
|
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
|
|
|
end
|
|
|
|
end
|
2019-07-09 15:57:48 +02:00
|
|
|
|
2020-09-17 17:09:16 +02:00
|
|
|
factory :champ_titre_identite, class: 'Champs::TitreIdentiteChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_titre_identite, procedure: dossier.procedure }
|
|
|
|
|
|
|
|
after(:build) do |champ, _evaluator|
|
|
|
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.png", content_type: "image/png")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_carte, class: 'Champs::CarteChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_carte, procedure: dossier.procedure }
|
|
|
|
end
|
2019-07-09 15:57:48 +02:00
|
|
|
|
2020-09-22 16:04:57 +02:00
|
|
|
factory :champ_iban, class: 'Champs::IbanChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_iban, procedure: dossier.procedure }
|
|
|
|
end
|
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_siret, class: 'Champs::SiretChamp' do
|
|
|
|
association :type_de_champ, factory: [:type_de_champ_siret]
|
|
|
|
association :etablissement, factory: [:etablissement]
|
|
|
|
value { '44011762001530' }
|
2019-07-09 15:57:48 +02:00
|
|
|
end
|
2019-09-03 15:17:19 +02:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_repetition, class: 'Champs::RepetitionChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_repetition, procedure: dossier.procedure }
|
|
|
|
|
|
|
|
after(:build) do |champ_repetition, _evaluator|
|
|
|
|
types_de_champ = champ_repetition.type_de_champ.types_de_champ
|
|
|
|
existing_type_de_champ_text = types_de_champ.find { |tdc| tdc.libelle == 'Nom' }
|
|
|
|
type_de_champ_text = existing_type_de_champ_text || build(
|
|
|
|
:type_de_champ_text,
|
2020-08-27 19:55:37 +02:00
|
|
|
position: 0,
|
2020-07-20 17:18:44 +02:00
|
|
|
parent: champ_repetition.type_de_champ,
|
|
|
|
libelle: 'Nom'
|
|
|
|
)
|
|
|
|
|
|
|
|
existing_type_de_champ_number = types_de_champ.find { |tdc| tdc.libelle == 'Age' }
|
|
|
|
type_de_champ_number = existing_type_de_champ_number || build(
|
|
|
|
:type_de_champ_number,
|
2020-08-27 19:55:37 +02:00
|
|
|
position: 1,
|
2020-07-20 17:18:44 +02:00
|
|
|
parent: champ_repetition.type_de_champ,
|
|
|
|
libelle: 'Age'
|
|
|
|
)
|
|
|
|
|
2020-08-27 19:55:37 +02:00
|
|
|
champ_repetition.type_de_champ.types_de_champ << [type_de_champ_text, type_de_champ_number]
|
2020-07-20 17:18:44 +02:00
|
|
|
champ_repetition.champs << [
|
|
|
|
build(:champ_text, dossier: champ_repetition.dossier, row: 0, type_de_champ: type_de_champ_text, parent: champ_repetition),
|
|
|
|
build(:champ_number, dossier: champ_repetition.dossier, row: 0, type_de_champ: type_de_champ_number, parent: champ_repetition),
|
|
|
|
build(:champ_text, dossier: champ_repetition.dossier, row: 1, type_de_champ: type_de_champ_text, parent: champ_repetition),
|
|
|
|
build(:champ_number, dossier: champ_repetition.dossier, row: 1, type_de_champ: type_de_champ_number, parent: champ_repetition)
|
|
|
|
]
|
|
|
|
end
|
2019-09-03 15:17:19 +02:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
trait :without_champs do
|
|
|
|
after(:build) do |champ_repetition, _evaluator|
|
|
|
|
champ_repetition.champs = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-03 15:17:19 +02:00
|
|
|
|
2020-07-20 17:18:44 +02:00
|
|
|
factory :champ_repetition_with_piece_jointe, class: 'Champs::RepetitionChamp' do
|
|
|
|
type_de_champ { association :type_de_champ_repetition, procedure: dossier.procedure }
|
|
|
|
|
|
|
|
after(:build) do |champ_repetition, _evaluator|
|
|
|
|
type_de_champ_pj0 = build(:type_de_champ_piece_justificative,
|
2020-08-27 19:55:37 +02:00
|
|
|
position: 0,
|
2020-07-20 17:18:44 +02:00
|
|
|
parent: champ_repetition.type_de_champ,
|
|
|
|
libelle: 'Justificatif de domicile')
|
|
|
|
type_de_champ_pj1 = build(:type_de_champ_piece_justificative,
|
2020-08-27 19:55:37 +02:00
|
|
|
position: 1,
|
2020-07-20 17:18:44 +02:00
|
|
|
parent: champ_repetition.type_de_champ,
|
|
|
|
libelle: 'Carte d\'identité')
|
|
|
|
|
|
|
|
champ_repetition.champs << [
|
|
|
|
build(:champ_piece_justificative, dossier: champ_repetition.dossier, row: 0, type_de_champ: type_de_champ_pj0),
|
|
|
|
build(:champ_piece_justificative, dossier: champ_repetition.dossier, row: 0, type_de_champ: type_de_champ_pj1),
|
|
|
|
build(:champ_piece_justificative, dossier: champ_repetition.dossier, row: 1, type_de_champ: type_de_champ_pj0),
|
|
|
|
build(:champ_piece_justificative, dossier: champ_repetition.dossier, row: 1, type_de_champ: type_de_champ_pj1)
|
|
|
|
]
|
|
|
|
end
|
2019-09-03 15:17:19 +02:00
|
|
|
end
|
|
|
|
end
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|