Skip to content

Commit

Permalink
fix(dossier): exclude brouillons from recherche
Browse files Browse the repository at this point in the history
  • Loading branch information
E-L-T authored and LeSim committed Aug 29, 2023
1 parent 019392c commit 0bc7d61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/recherche_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def index
# to make it simpler we only do it if the @search_terms is an id
return if !DossierSearchService.id_compatible?(@search_terms)

dossier_instructeur_searched_for = Dossier.find_by(id: @search_terms)
dossier_instructeur_searched_for = Dossier.state_not_brouillon.find_by(id: @search_terms)

return if dossier_instructeur_searched_for.nil?
return if current_instructeur&.groupe_instructeur_ids&.include?(dossier_instructeur_searched_for.groupe_instructeur_id)
Expand Down
14 changes: 14 additions & 0 deletions spec/controllers/recherche_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@
end
end

context 'when dossier is brouillon without groupe instructeur' do
let(:dossier2) { create(:dossier, :brouillon, procedure: procedure) }
let(:query) { dossier2.id }
before { dossier2.update(groupe_instructeur_id: nil) }

it { is_expected.to have_http_status(200) }

it 'does not return the dossier' do
subject
expect(assigns(:projected_dossiers).count).to eq(0)
expect(assigns(:dossier_not_in_instructor_group)).to eq(nil)
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) }
Expand Down

0 comments on commit 0bc7d61

Please sign in to comment.