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'
|
2015-09-22 11:56:14 +02:00
|
|
|
libelle 'Demande de subvention'
|
|
|
|
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
|
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
|
|
|
|
|
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|
|
2015-11-05 11:21:44 +01:00
|
|
|
type_de_champ = create(:type_de_champ)
|
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-03-15 17:17:56 +01:00
|
|
|
trait :with_type_de_champ_mandatory do
|
|
|
|
after(:build) do |procedure, _evaluator|
|
|
|
|
type_de_champ = create(:type_de_champ, mandatory: true)
|
|
|
|
|
|
|
|
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|
|
|
|
|
type_de_champ = create(:type_de_champ, mandatory: true, type_champ: :datetime)
|
|
|
|
|
|
|
|
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|
|
|
|
|
rib = create(:type_de_piece_justificative, :rib)
|
2015-09-22 13:15:58 +02:00
|
|
|
msa = create(:type_de_piece_justificative, :msa)
|
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
|