display batch operation alert to instructeur groups not only instructeur
This commit is contained in:
parent
c52443f221
commit
6859882a58
3 changed files with 22 additions and 21 deletions
|
@ -91,17 +91,9 @@ module Instructeurs
|
|||
|
||||
assign_exports
|
||||
|
||||
# Set procedure_batchs to display alerts in view
|
||||
# TO DO // récupérer les batchs du groupe d'instructeurs au lieu de l'instructeur
|
||||
return if current_instructeur.batch_operations.blank?
|
||||
# extraire un dossier de chaque batch pour voir quel procedure est rattaché -> et les ajouter à un tableau
|
||||
@procedure_batchs = []
|
||||
current_instructeur.batch_operations.each do |batch|
|
||||
random_batch_dossier_id = (batch.failed_dossier_ids + batch.success_dossier_ids + batch.dossiers.ids).sample
|
||||
if Dossier.find(random_batch_dossier_id).procedure.id == @procedure.id
|
||||
@procedure_batchs << batch
|
||||
end
|
||||
end
|
||||
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||
.distinct
|
||||
end
|
||||
|
||||
def deleted_dossiers
|
||||
|
|
|
@ -71,9 +71,9 @@
|
|||
%div{ data: { controller: 'batch-operation' } }
|
||||
- batch_operation_component = Dossiers::BatchOperationComponent.new(statut: @statut, procedure: @procedure)
|
||||
|
||||
- if @procedure_batchs.present?
|
||||
- @procedure_batchs.each do |batch|
|
||||
= render Dossiers::BatchAlertComponent.new(batch: batch, procedure: @procedure)
|
||||
- if @batch_operations.present?
|
||||
- @batch_operations.each do |batch_operation|
|
||||
= render Dossiers::BatchAlertComponent.new(batch: batch_operation, procedure: @procedure)
|
||||
|
||||
.flex
|
||||
.flex-grow= render batch_operation_component
|
||||
|
|
|
@ -342,22 +342,31 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
it { expect(assigns(:filtered_sorted_paginated_ids)).to match_array([termine_dossier, termine_dossier_on_gi_2].map(&:id)) }
|
||||
end
|
||||
|
||||
context 'with batch operations' do
|
||||
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur) }
|
||||
context 'with batch operations attached to the instructeur and his group' do
|
||||
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur, groupe_instructeurs: [gi_2]) }
|
||||
|
||||
let!(:termine_dossier_2) { create(:dossier, :accepte, procedure: procedure) }
|
||||
let!(:batch_operation_2) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier_2], instructeur: instructeur) }
|
||||
let!(:batch_operation_2) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier_2], instructeur: instructeur, groupe_instructeurs: [gi_2]) }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(assigns(:procedure_batchs)).to match_array([batch_operation, batch_operation_2]) }
|
||||
it { expect(assigns(:batch_operations)).to match_array([batch_operation, batch_operation_2]) }
|
||||
end
|
||||
|
||||
context 'with a batch operation not attached to the instructeur' do
|
||||
context 'with a batch operation not attached to the instructeur and his group' do
|
||||
let(:instructeur_2) { create(:instructeur) }
|
||||
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur_2) }
|
||||
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur_2, groupe_instructeurs: [gi_3]) }
|
||||
before { subject }
|
||||
|
||||
it { expect(assigns(:procedure_batchs)).to eq(nil) }
|
||||
it { expect(assigns(:batch_operations)).to eq([]) }
|
||||
end
|
||||
|
||||
context 'with a batch operation not attached to the instructeur but to his group' do
|
||||
let(:instructeur_2) { create(:instructeur) }
|
||||
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur_2, groupe_instructeurs: [gi_2]) }
|
||||
before { subject }
|
||||
|
||||
it { expect(assigns(:batch_operations)).to match_array([batch_operation]) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue