remove render_views in spec and correct the way to retrieve dossiers

This commit is contained in:
Lisa Durand 2022-11-04 16:02:51 +01:00 committed by mfo
parent ba0799b684
commit d245e12559
2 changed files with 3 additions and 6 deletions

View file

@ -32,7 +32,7 @@ class RechercheController < ApplicationController
# we want to retrieve dossiers that are not accessible to the instructor because he is not in the instructor group
# to display an alert in the view
instructeur_procedure_dossiers_ids = DossierSearchService
.matching_dossiers(current_instructeur&.procedures&.map(&:dossiers)&.first, @search_terms, with_annotation: true)
.matching_dossiers(Dossier.joins(:procedure).where(procedure: {id: current_instructeur&.procedures&.ids}), @search_terms, with_annotation: true)
not_in_instructor_group_dossiers_ids = instructeur_procedure_dossiers_ids - matching_dossiers_ids

View file

@ -1,6 +1,4 @@
describe RechercheController, type: :controller do
render_views
let(:procedure) {
create(:procedure,
:published,
@ -76,7 +74,7 @@ describe RechercheController, type: :controller do
it 'does not return the dossier' do
subject
expect(assigns(:projected_dossiers).count).to eq(0)
expect(response.body).not_to match(/<div class='fr-alert fr-alert--info/)
expect(assigns(:not_in_instructor_group_dossiers).count).to eq(0)
end
end
@ -94,8 +92,7 @@ describe RechercheController, type: :controller do
it 'does not return the dossier but it returns a message' do
subject
expect(assigns(:projected_dossiers).count).to eq(0)
expect(response.body).to match(/Aucun dossier correspondant à votre recherche na été trouvé/)
expect(CGI.unescapeHTML(response.body)).to match(/Le dossier n° #{dossier3.id} de la procédure « #{dossier3.procedure.libelle} » correspond à votre recherche mais il est rattaché au groupe d'instructeurs « #{dossier3.groupe_instructeur.label} »./)
expect(assigns(:not_in_instructor_group_dossiers)).to eq([dossier3])
end
end