2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use, class: 'Champ' do
|
2024-03-15 14:56:46 +01:00
|
|
|
stream { 'main' }
|
2020-07-20 17:18:44 +02:00
|
|
|
add_attribute(:private) { false }
|
2017-07-11 16:50:29 +02:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_text, class: 'Champs::TextChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { 'text' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_textarea, class: 'Champs::TextareaChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { 'textarea' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_date, class: 'Champs::DateChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '2019-07-10' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_datetime, class: 'Champs::DatetimeChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '15/09/1962 15:35' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_number, class: 'Champs::NumberChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '42' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_decimal_number, class: 'Champs::DecimalNumberChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '42.1' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_integer_number, class: 'Champs::IntegerNumberChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '42' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_checkbox, class: 'Champs::CheckboxChamp' do
|
2023-01-05 12:18:27 +01:00
|
|
|
value { 'true' }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_civilite, class: 'Champs::CiviliteChamp' do
|
2022-12-19 22:00:22 +01:00
|
|
|
value { 'M.' }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_email, class: 'Champs::EmailChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { 'yoda@beta.gouv.fr' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_phone, class: 'Champs::PhoneChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '0666666666' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_address, class: 'Champs::AddressChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '2 rue des Démarches' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_yes_no, class: 'Champs::YesNoChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { 'true' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_drop_down_list, class: 'Champs::DropDownListChamp' do
|
2022-08-02 12:57:41 +02:00
|
|
|
transient do
|
|
|
|
other { false }
|
|
|
|
end
|
2023-01-18 09:47:22 +01:00
|
|
|
value { 'val1' }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_multiple_drop_down_list, class: 'Champs::MultipleDropDownListChamp' do
|
2023-01-24 15:10:25 +01:00
|
|
|
value { '["val1", "val2"]' }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_linked_drop_down_list, class: 'Champs::LinkedDropDownListChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '["categorie 1", "choix 1"]' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_pays, class: 'Champs::PaysChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { 'France' }
|
|
|
|
end
|
2020-01-14 18:46:07 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_regions, class: 'Champs::RegionChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { 'Guadeloupe' }
|
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_departements, class: 'Champs::DepartementChamp' do
|
2023-02-20 06:57:41 +01:00
|
|
|
value { '01' }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_communes, class: 'Champs::CommuneChamp' do
|
2023-10-13 16:06:26 +02:00
|
|
|
external_id { '60172' }
|
|
|
|
code_postal { '60580' }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_epci, class: 'Champs::EpciChamp' do
|
2023-01-19 09:43:19 +01:00
|
|
|
value { 'CC Retz en Valois' }
|
|
|
|
external_id { '200071991' }
|
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_header_section, class: 'Champs::HeaderSectionChamp' do
|
2023-03-24 10:31:01 +01:00
|
|
|
value { 'une section' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_explication, class: 'Champs::ExplicationChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
value { '' }
|
2018-11-13 18:48:04 +01:00
|
|
|
end
|
2018-11-22 00:14:16 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_dossier_link, class: 'Champs::DossierLinkChamp' do
|
|
|
|
value { create(:dossier, :en_construction).id }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2018-12-18 11:17:52 +01:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
2021-06-02 11:10:44 +02:00
|
|
|
transient do
|
|
|
|
size { 4 }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |champ, evaluator|
|
2021-09-02 12:26:57 +02:00
|
|
|
champ.piece_justificative_file.attach(
|
|
|
|
io: StringIO.new("x" * evaluator.size),
|
|
|
|
filename: "toto.txt",
|
|
|
|
content_type: "text/plain",
|
|
|
|
# we don't want to run virus scanner on this file
|
|
|
|
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
|
|
|
|
)
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
|
|
|
end
|
2019-07-09 15:57:48 +02:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_titre_identite, class: 'Champs::TitreIdentiteChamp' do
|
2022-10-25 14:14:24 +02:00
|
|
|
transient do
|
|
|
|
skip_default_attachment { false }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |champ, evaluator|
|
|
|
|
next if evaluator.skip_default_attachment
|
2020-09-17 17:09:16 +02:00
|
|
|
|
2021-09-02 12:26:57 +02:00
|
|
|
champ.piece_justificative_file.attach(
|
|
|
|
io: StringIO.new("toto"),
|
|
|
|
filename: "toto.png",
|
|
|
|
content_type: "image/png",
|
|
|
|
# we don't want to run virus scanner on this file
|
|
|
|
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
|
|
|
|
)
|
2020-09-17 17:09:16 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_carte, class: 'Champs::CarteChamp' do
|
|
|
|
geo_areas { build_list(:geo_area, 2) }
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2019-07-09 15:57:48 +02:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_iban, class: 'Champs::IbanChamp' do
|
2020-09-22 16:04:57 +02:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_annuaire_education, class: 'Champs::AnnuaireEducationChamp' do
|
2021-01-14 17:29:57 +01:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_cnaf, class: 'Champs::CnafChamp' do
|
2021-09-24 14:21:30 +02:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_dgfip, class: 'Champs::DgfipChamp' do
|
2021-11-24 17:30:35 +01:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_pole_emploi, class: 'Champs::PoleEmploiChamp' do
|
2021-12-01 10:21:30 +01:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_mesri, class: 'Champs::MesriChamp' do
|
2021-12-15 15:25:02 +01:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_siret, class: 'Champs::SiretChamp' do
|
2020-07-20 17:18:44 +02:00
|
|
|
association :etablissement, factory: [:etablissement]
|
|
|
|
value { '44011762001530' }
|
2024-08-22 10:18:50 +02:00
|
|
|
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself) }
|
2019-07-09 15:57:48 +02:00
|
|
|
end
|
2019-09-03 15:17:19 +02:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_rna, class: 'Champs::RNAChamp' do
|
2022-09-21 15:18:08 +02:00
|
|
|
value { 'W173847273' }
|
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_engagement_juridique, class: 'Champs::EngagementJuridiqueChamp' do
|
2024-03-15 14:56:46 +01:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_cojo, class: 'Champs::COJOChamp' do
|
2024-03-15 14:56:46 +01:00
|
|
|
end
|
2023-05-30 14:42:36 +02:00
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_rnf, class: 'Champs::RNFChamp' do
|
2023-10-27 14:20:40 +02:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_expression_reguliere, class: 'Champs::ExpressionReguliereChamp' do
|
2023-09-29 23:09:41 +02:00
|
|
|
end
|
|
|
|
|
2024-07-01 15:31:32 +02:00
|
|
|
factory :champ_do_not_use_repetition, class: 'Champs::RepetitionChamp' do
|
2021-07-21 10:45:59 +02:00
|
|
|
transient do
|
|
|
|
rows { 2 }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |champ_repetition, evaluator|
|
2024-07-01 15:31:32 +02:00
|
|
|
revision = champ_repetition.type_de_champ.procedure.active_revision
|
|
|
|
parent = revision.revision_types_de_champ.find { _1.type_de_champ == champ_repetition.type_de_champ }
|
|
|
|
types_de_champ = revision.revision_types_de_champ.filter { _1.parent == parent }.map(&:type_de_champ)
|
2022-05-18 10:52:25 +02:00
|
|
|
|
2022-12-16 15:07:26 +01:00
|
|
|
evaluator.rows.times do
|
|
|
|
row_id = ULID.generate
|
2024-09-27 15:44:57 +02:00
|
|
|
champ_repetition.dossier.champs << types_de_champ.map do |type_de_champ|
|
|
|
|
attrs = { dossier: champ_repetition.dossier, private: champ_repetition.private?, stable_id: type_de_champ.stable_id, row_id: }
|
2024-07-01 15:31:32 +02:00
|
|
|
build(:"champ_do_not_use_#{type_de_champ.type_champ}", **attrs)
|
2022-07-21 10:01:10 +02:00
|
|
|
end
|
2021-07-21 10:45:59 +02:00
|
|
|
end
|
2020-07-20 17:18:44 +02:00
|
|
|
end
|
2019-09-03 15:17:19 +02:00
|
|
|
end
|
|
|
|
end
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|