2015-09-21 17:59:03 +02:00
|
|
|
FactoryGirl.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
|
|
|
|
lien_demarche 'http://localhost'
|
2017-04-12 11:18:28 +02:00
|
|
|
sequence(:libelle) { |n| "Procedure #{n}" }
|
2015-09-22 11:56:14 +02:00
|
|
|
description "Demande de subvention à l'intention des associations"
|
2015-12-21 17:51:08 +01:00
|
|
|
organisation "Orga SGMAP"
|
|
|
|
direction "direction SGMAP"
|
2016-06-09 17:49:38 +02:00
|
|
|
published false
|
2017-02-15 17:09:25 +01:00
|
|
|
cerfa_flag false
|
2016-06-24 16:41:44 +02:00
|
|
|
administrateur { create(:administrateur) }
|
2015-09-21 17:59:03 +02:00
|
|
|
|
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
|
|
|
|
|
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
|
2015-10-27 17:31:08 +01:00
|
|
|
after(:build) do |procedure, _evaluator|
|
2016-08-03 18:19:56 +02:00
|
|
|
type_de_champ = create(:type_de_champ_public)
|
2015-10-27 17:31:08 +01:00
|
|
|
|
2015-11-05 11:21:44 +01:00
|
|
|
procedure.types_de_champ << type_de_champ
|
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
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
type_de_champ = create(:type_de_champ_private)
|
|
|
|
|
|
|
|
procedure.types_de_champ_private << type_de_champ
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-15 17:17:56 +01:00
|
|
|
trait :with_type_de_champ_mandatory do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
2016-08-03 18:19:56 +02:00
|
|
|
type_de_champ = create(:type_de_champ_public, 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|
|
2016-08-03 18:19:56 +02:00
|
|
|
type_de_champ = create(:type_de_champ_public, mandatory: true, type_champ: :datetime)
|
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|
|
|
|
|
type_de_champ = create(:type_de_champ_public, :type_dossier_link)
|
|
|
|
|
|
|
|
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
|
2016-06-24 16:41:44 +02:00
|
|
|
after(:create) 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
|
2015-09-21 17:59:03 +02:00
|
|
|
end
|
|
|
|
end
|