2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2016-06-09 12:08:18 +02:00
|
|
|
factory :champ do
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ { create(:type_de_champ) }
|
2017-07-11 16:50:29 +02:00
|
|
|
|
|
|
|
trait :checkbox do
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ { create(:type_de_champ_checkbox) }
|
2017-07-11 16:50:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :header_section do
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ { create(:type_de_champ_header_section) }
|
2017-07-11 16:50:29 +02:00
|
|
|
end
|
2017-10-03 15:08:39 +02:00
|
|
|
|
|
|
|
trait :explication do
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ { create(:type_de_champ_explication) }
|
2017-10-03 15:08:39 +02:00
|
|
|
end
|
2017-11-21 17:20:52 +01:00
|
|
|
|
|
|
|
trait :dossier_link do
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ { create(:type_de_champ_dossier_link) }
|
2017-11-21 17:20:52 +01:00
|
|
|
end
|
2018-05-11 14:59:20 +02:00
|
|
|
|
|
|
|
trait :piece_justificative do
|
|
|
|
type_de_champ { create(:type_de_champ_piece_justificative) }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_piece_justificative_file do
|
|
|
|
after(:create) do |champ, evaluator|
|
|
|
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
|
|
|
end
|
|
|
|
end
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2018-11-22 00:14:16 +01:00
|
|
|
factory :champ_text, class: 'Champs::TextChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_text) }
|
|
|
|
value { 'text' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_textarea, class: 'Champs::TextareaChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_textarea) }
|
|
|
|
value { 'textarea' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_date, class: 'Champs::DateChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_date) }
|
|
|
|
value { 1.day.ago.iso8601 }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_datetime, class: 'Champs::DatetimeChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_datetime) }
|
|
|
|
value { 1.day.ago.iso8601 }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_number, class: 'Champs::NumberChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_number) }
|
2018-11-13 18:48:04 +01:00
|
|
|
value { '42' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_decimal_number, class: 'Champs::DecimalNumberChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_decimal_number) }
|
|
|
|
value { '42.1' }
|
|
|
|
end
|
|
|
|
|
2018-11-22 00:14:16 +01:00
|
|
|
factory :champ_integer_number, class: 'Champs::IntegerNumberChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_integer_number) }
|
|
|
|
value { '42' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_checkbox, class: 'Champs::CheckboxChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_checkbox) }
|
|
|
|
value { 'on' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_civilite, class: 'Champs::CiviliteChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_civilite) }
|
|
|
|
value { 'M.' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_email, class: 'Champs::EmailChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_email) }
|
|
|
|
value { 'yoda@beta.gouv.fr' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_phone, class: 'Champs::PhoneChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_phone) }
|
|
|
|
value { '0666666666' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_address, class: 'Champs::AddressChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_address) }
|
|
|
|
value { '2 rue des Démarches' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_yes_no, class: 'Champs::YesNoChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_yes_no) }
|
|
|
|
value { 'true' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_drop_down_list, class: 'Champs::DropDownListChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_drop_down_list) }
|
|
|
|
value { '' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_multiple_drop_down_list, class: 'Champs::MultipleDropDownListChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_multiple_drop_down_list) }
|
|
|
|
value { '' }
|
|
|
|
end
|
|
|
|
|
2018-11-13 18:48:04 +01:00
|
|
|
factory :champ_linked_drop_down_list, class: 'Champs::LinkedDropDownListChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_linked_drop_down_list) }
|
|
|
|
value { '{}' }
|
|
|
|
end
|
|
|
|
|
2018-11-22 00:14:16 +01:00
|
|
|
factory :champ_pays, class: 'Champs::PaysChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_pays) }
|
|
|
|
value { 'France' }
|
2018-11-13 18:48:04 +01:00
|
|
|
end
|
|
|
|
|
2018-11-22 00:14:16 +01:00
|
|
|
factory :champ_regions, class: 'Champs::RegionChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_regions) }
|
|
|
|
value { '' }
|
|
|
|
end
|
2018-11-13 18:48:04 +01:00
|
|
|
|
2018-11-22 00:14:16 +01:00
|
|
|
factory :champ_departements, class: 'Champs::DepartementChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_departements) }
|
|
|
|
value { '' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_engagement, class: 'Champs::EngagementChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_engagement) }
|
|
|
|
value { 'true' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_header_section, class: 'Champs::HeaderSectionChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_header_section) }
|
|
|
|
value { 'une section' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_explication, class: 'Champs::ExplicationChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_explication) }
|
|
|
|
value { 'une explication' }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_dossier_link, class: 'Champs::DossierLinkChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_dossier_link) }
|
|
|
|
value { create(:dossier).id }
|
2018-11-13 18:48:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_piece_justificative) }
|
|
|
|
|
|
|
|
after(:create) do |champ, evaluator|
|
|
|
|
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
|
|
|
|
|
|
|
factory :champ_carte, class: 'Champs::CarteChamp' do
|
|
|
|
type_de_champ { create(:type_de_champ_carte) }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :champ_siret, class: 'Champs::SiretChamp' do
|
|
|
|
association :type_de_champ, factory: [:type_de_champ_siret]
|
|
|
|
association :etablissement, factory: [:etablissement]
|
|
|
|
value { '44011762001530' }
|
|
|
|
|
|
|
|
after(:build) do |champ, evaluator|
|
|
|
|
champ.etablissement.signature = champ.etablissement.sign
|
|
|
|
end
|
|
|
|
end
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|