correctif(test): desormais l'association batch_operations.groupe_instructeurs passe par le dossier. Mise a jour des tests

This commit is contained in:
Martin 2023-01-03 11:17:18 +01:00 committed by Lisa Durand
parent 018a94f43b
commit 3918757dc9
3 changed files with 6 additions and 5 deletions

View file

@ -1,6 +1,6 @@
.fr-mb-5v
- if @batch.finished_at.present?
= render Dsfr::AlertComponent.new(title: t(".#{batch.operation}.finish.title"), state: (@batch.errors? ? :warning : :success), heading_level: 'h2') do |c|
= render Dsfr::AlertComponent.new(title: t(".title.finish"), state: (@batch.errors? ? :warning : :success), heading_level: 'h2') do |c|
- c.body do
%p
= t(".#{batch.operation}.finish.text_success", count: @batch.total_count, success_count: @batch.success_count)

View file

@ -90,7 +90,6 @@ module Instructeurs
@projected_dossiers = DossierProjectionService.project(@filtered_sorted_paginated_ids, procedure_presentation.displayed_fields)
assign_exports
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
.where(seen_at: nil)

View file

@ -343,18 +343,20 @@ describe Instructeurs::ProceduresController, type: :controller do
end
context 'with batch operations' do
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur, groupe_instructeurs: instructeur.groupe_instructeurs) }
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur) }
let!(:termine_dossier_2) { create(:dossier, :accepte, procedure: procedure) }
let!(:batch_operation_2) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier_2], instructeur: instructeur, groupe_instructeurs: instructeur.groupe_instructeurs) }
let!(:batch_operation_2) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier_2], instructeur: instructeur) }
before { subject }
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 dossier in a groupe instructeur where current instructeur is not ' do
let(:instructeur_2) { create(:instructeur) }
let!(:termine_dossier) { create(:dossier, :accepte, procedure: procedure, groupe_instructeur: gi_3) }
let!(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [termine_dossier], instructeur: instructeur_2) }
before { subject }
it { expect(assigns(:batch_operations)).to eq([]) }