demarches-normaliennes/spec/factories/procedure.rb

66 lines
1.8 KiB
Ruby
Raw Normal View History

FactoryGirl.define do
sequence(:published_path) { |n| "fake_path#{n}" }
factory :procedure do
lien_demarche 'http://localhost'
libelle 'Demande de subvention'
description "Demande de subvention à l'intention des associations"
organisation "Orga SGMAP"
direction "direction SGMAP"
published false
administrateur { create(:administrateur) }
after(:build) do |procedure, _evaluator|
if procedure.module_api_carto.nil?
module_api_carto = create(:module_api_carto)
procedure.module_api_carto = module_api_carto
end
end
trait :with_api_carto do
after(:build) do |procedure, _evaluator|
procedure.module_api_carto.use_api_carto = true
end
end
2015-11-05 11:21:44 +01:00
trait :with_type_de_champ do
after(:build) do |procedure, _evaluator|
2015-11-05 11:21:44 +01:00
type_de_champ = create(:type_de_champ)
2015-11-05 11:21:44 +01:00
procedure.types_de_champ << type_de_champ
end
end
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
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
trait :with_two_type_de_piece_justificative do
after(:build) do |procedure, _evaluator|
rib = create(:type_de_piece_justificative, :rib)
msa = create(:type_de_piece_justificative, :msa)
procedure.types_de_piece_justificative << rib
procedure.types_de_piece_justificative << msa
end
end
trait :published do
after(:create) do |procedure, _evaluator|
2016-07-12 15:20:10 +02:00
procedure.publish!(generate(:published_path))
end
end
end
end