2018-01-23 17:15:42 +01:00
|
|
|
FactoryBot.define do
|
2016-06-24 16:41:44 +02:00
|
|
|
sequence(:published_path) { |n| "fake_path#{n}" }
|
2015-09-21 17:59:03 +02:00
|
|
|
factory :procedure do
|
2017-04-12 11:18:28 +02:00
|
|
|
sequence(:libelle) { |n| "Procedure #{n}" }
|
2018-09-04 16:46:48 +02:00
|
|
|
description { "Demande de subvention à l'intention des associations" }
|
|
|
|
organisation { "Orga DINSIC" }
|
|
|
|
direction { "direction DINSIC" }
|
|
|
|
cadre_juridique { "un cadre juridique important" }
|
|
|
|
published_at { nil }
|
2016-06-24 16:41:44 +02:00
|
|
|
administrateur { create(:administrateur) }
|
2018-09-04 16:46:48 +02:00
|
|
|
duree_conservation_dossiers_dans_ds { 3 }
|
|
|
|
duree_conservation_dossiers_hors_ds { 6 }
|
2015-09-21 17:59:03 +02:00
|
|
|
|
2018-07-03 20:18:06 +02:00
|
|
|
factory :procedure_with_dossiers do
|
|
|
|
transient do
|
2018-09-04 16:46:48 +02:00
|
|
|
dossiers_count { 1 }
|
2018-07-03 20:18:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.dossiers << create_list(:dossier, _evaluator.dossiers_count, procedure: procedure)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-24 15:54:46 +02:00
|
|
|
factory :simple_procedure do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.for_individual = true
|
|
|
|
procedure.types_de_champ << create(:type_de_champ, libelle: 'Texte obligatoire', mandatory: true)
|
|
|
|
procedure.publish!(generate(:published_path))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-08 10:11:58 +01:00
|
|
|
after(:build) do |procedure, _evaluator|
|
2015-12-08 11:18:49 +01:00
|
|
|
if procedure.module_api_carto.nil?
|
|
|
|
module_api_carto = create(:module_api_carto)
|
|
|
|
procedure.module_api_carto = module_api_carto
|
|
|
|
end
|
2015-12-08 10:11:58 +01:00
|
|
|
end
|
|
|
|
|
2018-08-13 17:49:15 +02:00
|
|
|
trait :with_path do
|
|
|
|
after(:create) do |procedure|
|
|
|
|
create(:procedure_path,
|
|
|
|
procedure: procedure,
|
|
|
|
administrateur: procedure.administrateur,
|
|
|
|
path: generate(:published_path))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-19 16:23:43 +02:00
|
|
|
trait :with_service do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.service = create(:service)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-19 16:47:56 +01:00
|
|
|
trait :with_api_carto do
|
2015-12-08 10:11:58 +01:00
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.module_api_carto.use_api_carto = true
|
|
|
|
end
|
2015-11-19 16:47:56 +01:00
|
|
|
end
|
|
|
|
|
2016-12-19 17:15:59 +01:00
|
|
|
trait :for_individual do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.for_individual = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-05 11:21:44 +01:00
|
|
|
trait :with_type_de_champ do
|
2017-05-26 17:22:54 +02:00
|
|
|
transient do
|
2018-09-04 16:46:48 +02:00
|
|
|
types_de_champ_count { 1 }
|
2017-05-26 17:22:54 +02:00
|
|
|
end
|
2015-10-27 17:31:08 +01:00
|
|
|
|
2017-05-26 17:22:54 +02:00
|
|
|
after(:build) do |procedure, evaluator|
|
|
|
|
evaluator.types_de_champ_count.times do
|
2018-02-13 17:00:19 +01:00
|
|
|
type_de_champ = create(:type_de_champ)
|
2017-05-26 17:22:54 +02:00
|
|
|
|
|
|
|
procedure.types_de_champ << type_de_champ
|
|
|
|
end
|
2015-10-27 17:31:08 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-03 18:19:56 +02:00
|
|
|
trait :with_type_de_champ_private do
|
2017-10-02 17:03:38 +02:00
|
|
|
transient do
|
2018-09-04 16:46:48 +02:00
|
|
|
types_de_champ_private_count { 1 }
|
2017-10-02 17:03:38 +02:00
|
|
|
end
|
2016-08-03 18:19:56 +02:00
|
|
|
|
2017-10-02 17:03:38 +02:00
|
|
|
after(:build) do |procedure, evaluator|
|
|
|
|
evaluator.types_de_champ_private_count.times do
|
2018-02-13 17:00:19 +01:00
|
|
|
type_de_champ = create(:type_de_champ, :private)
|
2017-10-02 17:03:38 +02:00
|
|
|
|
|
|
|
procedure.types_de_champ_private << type_de_champ
|
|
|
|
end
|
2016-08-03 18:19:56 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-15 17:17:56 +01:00
|
|
|
trait :with_type_de_champ_mandatory do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2018-02-13 17:00:19 +01:00
|
|
|
type_de_champ = create(:type_de_champ, mandatory: true)
|
2016-03-15 17:17:56 +01:00
|
|
|
|
|
|
|
procedure.types_de_champ << type_de_champ
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-22 11:25:41 +02:00
|
|
|
trait :with_datetime do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ = create(:type_de_champ_datetime, mandatory: true)
|
2016-06-22 11:25:41 +02:00
|
|
|
|
|
|
|
procedure.types_de_champ << type_de_champ
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-04-17 17:20:32 +02:00
|
|
|
trait :with_dossier_link do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ = create(:type_de_champ_dossier_link)
|
2017-04-17 17:20:32 +02:00
|
|
|
|
|
|
|
procedure.types_de_champ << type_de_champ
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-26 11:00:36 +02:00
|
|
|
trait :with_yes_no do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2018-02-14 15:12:57 +01:00
|
|
|
type_de_champ = create(:type_de_champ_yes_no)
|
2017-06-26 11:00:36 +02:00
|
|
|
|
|
|
|
procedure.types_de_champ << type_de_champ
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-21 17:59:03 +02:00
|
|
|
trait :with_two_type_de_piece_justificative do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2017-04-13 14:48:18 +02:00
|
|
|
rib = create(:type_de_piece_justificative, :rib, order_place: 1)
|
|
|
|
msa = create(:type_de_piece_justificative, :msa, order_place: 2)
|
2015-09-21 17:59:03 +02:00
|
|
|
|
|
|
|
procedure.types_de_piece_justificative << rib
|
2015-09-22 13:15:58 +02:00
|
|
|
procedure.types_de_piece_justificative << msa
|
2015-09-21 17:59:03 +02:00
|
|
|
end
|
|
|
|
end
|
2016-06-09 17:49:38 +02:00
|
|
|
|
|
|
|
trait :published do
|
2018-05-17 15:42:51 +02:00
|
|
|
after(:build) do |procedure, _evaluator|
|
2016-07-12 15:20:10 +02:00
|
|
|
procedure.publish!(generate(:published_path))
|
2016-06-09 17:49:38 +02:00
|
|
|
end
|
|
|
|
end
|
2017-07-04 13:52:08 +02:00
|
|
|
|
|
|
|
trait :archived do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2018-05-17 15:42:51 +02:00
|
|
|
procedure.publish!(generate(:published_path))
|
|
|
|
procedure.archive!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :hidden do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.publish!(generate(:published_path))
|
|
|
|
procedure.hide!
|
2017-07-04 13:52:08 +02:00
|
|
|
end
|
|
|
|
end
|
2018-02-21 18:32:07 +01:00
|
|
|
|
2018-05-30 14:21:17 +02:00
|
|
|
trait :whitelisted do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
procedure.update(whitelisted_at: DateTime.now)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-26 14:36:27 +02:00
|
|
|
trait :with_notice do
|
|
|
|
after(:create) do |procedure, _evaluator|
|
|
|
|
procedure.notice.attach(
|
|
|
|
io: StringIO.new('Hello World'),
|
2018-05-31 11:00:22 +02:00
|
|
|
filename: 'hello.txt'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :with_deliberation do
|
|
|
|
after(:create) do |procedure, _evaluator|
|
|
|
|
procedure.deliberation.attach(
|
|
|
|
io: StringIO.new('Hello World'),
|
2018-04-26 14:36:27 +02:00
|
|
|
filename: 'hello.txt'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-21 18:32:07 +01:00
|
|
|
trait :with_all_champs_mandatory do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
tdcs = []
|
2018-02-14 15:12:57 +01:00
|
|
|
tdcs << create(:type_de_champ, mandatory: true, libelle: 'text')
|
|
|
|
tdcs << create(:type_de_champ_textarea, mandatory: true, libelle: 'textarea')
|
|
|
|
tdcs << create(:type_de_champ_date, mandatory: true, libelle: 'date')
|
|
|
|
tdcs << create(:type_de_champ_datetime, mandatory: true, libelle: 'datetime')
|
|
|
|
tdcs << create(:type_de_champ_number, mandatory: true, libelle: 'number')
|
|
|
|
tdcs << create(:type_de_champ_checkbox, mandatory: true, libelle: 'checkbox')
|
|
|
|
tdcs << create(:type_de_champ_civilite, mandatory: true, libelle: 'civilite')
|
|
|
|
tdcs << create(:type_de_champ_email, mandatory: true, libelle: 'email')
|
|
|
|
tdcs << create(:type_de_champ_phone, mandatory: true, libelle: 'phone')
|
|
|
|
tdcs << create(:type_de_champ_yes_no, mandatory: true, libelle: 'yes_no')
|
|
|
|
tdcs << create(:type_de_champ_drop_down_list, mandatory: true, libelle: 'simple_drop_down_list')
|
|
|
|
tdcs << create(:type_de_champ_multiple_drop_down_list, mandatory: true, libelle: 'multiple_drop_down_list')
|
|
|
|
tdcs << create(:type_de_champ_pays, mandatory: true, libelle: 'pays')
|
|
|
|
tdcs << create(:type_de_champ_regions, mandatory: true, libelle: 'regions')
|
|
|
|
tdcs << create(:type_de_champ_departements, mandatory: true, libelle: 'departements')
|
|
|
|
tdcs << create(:type_de_champ_engagement, mandatory: true, libelle: 'engagement')
|
|
|
|
tdcs << create(:type_de_champ_header_section, mandatory: true, libelle: 'header_section')
|
|
|
|
tdcs << create(:type_de_champ_explication, mandatory: true, libelle: 'explication')
|
|
|
|
tdcs << create(:type_de_champ_dossier_link, mandatory: true, libelle: 'dossier_link')
|
|
|
|
tdcs << create(:type_de_champ_piece_justificative, mandatory: true, libelle: 'piece_justificative')
|
2018-02-21 18:32:07 +01:00
|
|
|
procedure.types_de_champ = tdcs
|
|
|
|
end
|
|
|
|
end
|
2015-09-21 17:59:03 +02:00
|
|
|
end
|
|
|
|
end
|