2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-18 15:26:31 +01:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :batch_operation do
|
2022-11-19 06:03:59 +01:00
|
|
|
transient do
|
|
|
|
invalid_instructeur { nil }
|
|
|
|
end
|
2022-11-25 15:43:00 +01:00
|
|
|
|
2022-12-05 13:36:38 +01:00
|
|
|
association :instructeur
|
|
|
|
|
2022-11-18 16:59:46 +01:00
|
|
|
trait :archiver do
|
|
|
|
operation { BatchOperation.operations.fetch(:archiver) }
|
2022-12-02 17:16:29 +01:00
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2022-11-19 06:03:59 +01:00
|
|
|
batch_operation.dossiers = [
|
2022-11-25 15:43:00 +01:00
|
|
|
create(:dossier, :with_individual, :accepte, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :refuse, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :sans_suite, procedure: procedure)
|
2022-11-18 16:59:46 +01:00
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
2022-12-12 10:02:33 +01:00
|
|
|
|
2023-11-29 22:36:55 +01:00
|
|
|
trait :desarchiver do
|
|
|
|
operation { BatchOperation.operations.fetch(:desarchiver) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-11-29 22:36:55 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :accepte, procedure: procedure, archived: true),
|
|
|
|
create(:dossier, :with_individual, :refuse, procedure: procedure, archived: true),
|
|
|
|
create(:dossier, :with_individual, :sans_suite, procedure: procedure, archived: true)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-12-12 10:02:33 +01:00
|
|
|
trait :passer_en_instruction do
|
|
|
|
operation { BatchOperation.operations.fetch(:passer_en_instruction) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2022-12-12 10:02:33 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :en_construction, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :en_construction, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
2022-12-15 17:35:50 +01:00
|
|
|
|
2023-11-30 16:11:04 +01:00
|
|
|
trait :repousser_expiration do
|
|
|
|
operation { BatchOperation.operations.fetch(:repousser_expiration) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-11-30 16:11:04 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :accepte, procedure: procedure, processed_at: 12.months.ago),
|
|
|
|
create(:dossier, :with_individual, :accepte, procedure: procedure, processed_at: 12.months.ago)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-12-15 17:35:50 +01:00
|
|
|
trait :accepter do
|
|
|
|
operation { BatchOperation.operations.fetch(:accepter) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2022-12-15 17:35:50 +01:00
|
|
|
batch_operation.dossiers = [
|
2023-07-04 11:40:11 +02:00
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :refuser do
|
|
|
|
operation { BatchOperation.operations.fetch(:refuser) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-07-04 11:40:11 +02:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :classer_sans_suite do
|
|
|
|
operation { BatchOperation.operations.fetch(:classer_sans_suite) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-07-04 11:40:11 +02:00
|
|
|
batch_operation.dossiers = [
|
2022-12-15 17:35:50 +01:00
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
2023-01-04 11:51:22 +01:00
|
|
|
|
|
|
|
trait :follow do
|
|
|
|
operation { BatchOperation.operations.fetch(:follow) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-01-04 11:51:22 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :en_construction, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
2023-01-11 11:05:19 +01:00
|
|
|
|
2023-01-13 15:09:24 +01:00
|
|
|
trait :unfollow do
|
|
|
|
operation { BatchOperation.operations.fetch(:unfollow) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-01-13 15:09:24 +01:00
|
|
|
batch_operation.dossiers = [
|
2023-01-16 10:16:23 +01:00
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure, followers_instructeurs: procedure.instructeurs),
|
|
|
|
create(:dossier, :with_individual, :en_construction, procedure: procedure, followers_instructeurs: procedure.instructeurs)
|
2023-01-13 15:09:24 +01:00
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-11-29 19:40:51 +01:00
|
|
|
trait :restaurer do
|
|
|
|
operation { BatchOperation.operations.fetch(:restaurer) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-11-29 19:40:51 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :accepte, procedure: procedure, hidden_by_administration_at: Time.zone.now),
|
|
|
|
create(:dossier, :with_individual, :refuse, procedure: procedure, hidden_by_administration_at: Time.zone.now)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-01-11 11:05:19 +01:00
|
|
|
trait :repasser_en_construction do
|
|
|
|
operation { BatchOperation.operations.fetch(:repasser_en_construction) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-01-11 11:05:19 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :en_instruction, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
2023-11-16 10:30:16 +01:00
|
|
|
|
|
|
|
trait :supprimer do
|
|
|
|
operation { BatchOperation.operations.fetch(:supprimer) }
|
|
|
|
after(:build) do |batch_operation, evaluator|
|
2024-06-01 22:50:48 +02:00
|
|
|
procedure = create(:simple_procedure, :published, instructeurs: [evaluator.invalid_instructeur.presence || batch_operation.instructeur])
|
2023-11-16 10:30:16 +01:00
|
|
|
batch_operation.dossiers = [
|
|
|
|
create(:dossier, :with_individual, :accepte, procedure: procedure),
|
|
|
|
create(:dossier, :with_individual, :refuse, procedure: procedure)
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
2022-11-18 15:26:31 +01:00
|
|
|
end
|
|
|
|
end
|