it displays a message if instructor is looking for a dossier that is not in his instructor group
This commit is contained in:
parent
bb96c3a77d
commit
ba0799b684
5 changed files with 41 additions and 0 deletions
|
@ -28,6 +28,15 @@ class RechercheController < ApplicationController
|
|||
@dossiers_count = matching_dossiers_ids.count
|
||||
@followed_dossiers_id = current_instructeur&.followed_dossiers&.where(id: @paginated_ids)&.ids || []
|
||||
@dossier_avis_ids_h = current_expert&.avis&.where(dossier_id: @paginated_ids)&.pluck(:dossier_id, :id).to_h || {}
|
||||
|
||||
# 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)
|
||||
|
||||
not_in_instructor_group_dossiers_ids = instructeur_procedure_dossiers_ids - matching_dossiers_ids
|
||||
|
||||
@not_in_instructor_group_dossiers = Dossier.where(id: not_in_instructor_group_dossiers_ids)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
- content_for(:title, "Recherche : #{@search_terms}")
|
||||
|
||||
.container
|
||||
|
||||
- if @not_in_instructor_group_dossiers.present?
|
||||
.fr-alert.fr-alert--info.fr-alert--sm.fr-mt-3w
|
||||
- @not_in_instructor_group_dossiers.each do |dossier|
|
||||
= p t('views.instructeurs.search.not_in_instructor_group_dossier', dossier_id: dossier.id, procedure_libelle: dossier.procedure.libelle, groupe_instructeur_label: dossier.groupe_instructeur.label)
|
||||
|
||||
.page-title
|
||||
Résultat de la recherche :
|
||||
= t('pluralize.dossier_trouve', count: @dossiers_count)
|
||||
|
|
|
@ -182,6 +182,8 @@ en:
|
|||
dossier_synthesis: Summary of files
|
||||
avis:
|
||||
introduction_file_explaination: "File attached to the request for advice"
|
||||
search:
|
||||
not_in_instructor_group_dossier: "File no. %{dossier_id} of the “%{procedure_libelle}” procedure corresponds to your search, but it is attached to the “%{groupe_instructeur_label}” instructor group."
|
||||
users:
|
||||
dossiers:
|
||||
archived_dossier: "Your file will be kept %{duree_conservation_dossiers_dans_ds} more months"
|
||||
|
|
|
@ -178,6 +178,8 @@ fr:
|
|||
dossier_synthesis: Synthèse des dossiers
|
||||
avis:
|
||||
introduction_file_explaination: "Fichier joint à la demande d’avis"
|
||||
search:
|
||||
not_in_instructor_group_dossier: "Le dossier n° %{dossier_id} de la procédure « %{procedure_libelle} » correspond à votre recherche mais il est rattaché au groupe d'instructeurs « %{groupe_instructeur_label} »."
|
||||
users:
|
||||
dossiers:
|
||||
archived_dossier: "Votre dossier sera conservé %{duree_conservation_dossiers_dans_ds} mois supplémentaire"
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
describe RechercheController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:procedure) {
|
||||
create(:procedure,
|
||||
:published,
|
||||
|
@ -74,6 +76,26 @@ 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/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when instructeur is attached to the procedure but is not in the instructor group of the dossier' do
|
||||
let!(:gi_p1_1) { GroupeInstructeur.create(label: 'groupe 1', procedure: procedure) }
|
||||
let!(:gi_p1_2) { GroupeInstructeur.create(label: 'groupe 2', procedure: procedure) }
|
||||
let!(:dossier3) { create(:dossier, :accepte, :with_individual, procedure: procedure, groupe_instructeur: gi_p1_2) }
|
||||
|
||||
before { gi_p1_1.instructeurs << instructeur }
|
||||
|
||||
let(:query) { dossier3.id }
|
||||
|
||||
it { is_expected.to have_http_status(200) }
|
||||
|
||||
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 n’a é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} »./)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue