From 3918757dc98a48a83040a2a7ee3f6b4e076aa6d5 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 3 Jan 2023 11:17:18 +0100 Subject: [PATCH] correctif(test): desormais l'association batch_operations.groupe_instructeurs passe par le dossier. Mise a jour des tests --- .../batch_alert_component/batch_alert_component.html.haml | 2 +- app/controllers/instructeurs/procedures_controller.rb | 1 - .../instructeurs/procedures_controller_spec.rb | 8 +++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/components/dossiers/batch_alert_component/batch_alert_component.html.haml b/app/components/dossiers/batch_alert_component/batch_alert_component.html.haml index aadcbbba0..06eaec50f 100644 --- a/app/components/dossiers/batch_alert_component/batch_alert_component.html.haml +++ b/app/components/dossiers/batch_alert_component/batch_alert_component.html.haml @@ -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) diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 4fc045d93..3a1428604 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -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) diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index 33f0da6d7..c0ded97cb 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -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([]) }