From 2c87b3f92d5e6ff7b844f6cd1dee90bfce2333de Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 2 Dec 2024 18:53:02 +0100 Subject: [PATCH 1/8] clean dossier_search_service_spec --- spec/services/dossier_search_service_spec.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index 560e819b44e..c2d0b7f09c0 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -8,11 +8,8 @@ described_class.matching_dossiers(instructeur_1.dossiers, terms) end - let(:administrateur_1) { administrateurs(:default_admin) } - let(:administrateur_2) { administrateurs(:default_admin) } - - let(:instructeur_1) { create(:instructeur, administrateurs: [administrateur_1]) } - let(:instructeur_2) { create(:instructeur, administrateurs: [administrateur_2]) } + let(:instructeur_1) { create(:instructeur) } + let(:instructeur_2) { create(:instructeur) } before do instructeur_1.assign_to_procedure(procedure_1) @@ -29,8 +26,8 @@ perform_enqueued_jobs(only: DossierIndexSearchTermsJob) end - let(:procedure_1) { create(:procedure, :published, administrateur: administrateur_1) } - let(:procedure_2) { create(:procedure, :published, administrateur: administrateur_2) } + let(:procedure_1) { create(:procedure, :published) } + let(:procedure_2) { create(:procedure, :published) } let(:dossier_0) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } From 8c17dd6e1d03656ca76299708d5d52b22cf8c1be Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Dec 2024 11:55:13 +0100 Subject: [PATCH 2/8] clean dossier_search_service_spec matching_dossier --- spec/services/dossier_search_service_spec.rb | 121 +++++++------------ 1 file changed, 42 insertions(+), 79 deletions(-) diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index c2d0b7f09c0..0970862c812 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -2,106 +2,69 @@ describe DossierSearchService do describe '#matching_dossiers' do - subject { liste_dossiers } - - let(:liste_dossiers) do - described_class.matching_dossiers(instructeur_1.dossiers, terms) - end + let!(:dossiers) { Dossier.where(id: dossier.id) } - let(:instructeur_1) { create(:instructeur) } - let(:instructeur_2) { create(:instructeur) } + before { perform_enqueued_jobs(only: DossierIndexSearchTermsJob) } - before do - instructeur_1.assign_to_procedure(procedure_1) - instructeur_2.assign_to_procedure(procedure_2) + def searching(terms) = described_class.matching_dossiers(dossiers, terms) - # create dossier before performing jobs - # because let!() syntax is executed after "before" callback - dossier_0 - dossier_1 - dossier_2 - dossier_3 - dossier_archived + describe 'ignores brouillon' do + let(:dossier) { create(:dossier, state: :brouillon) } - perform_enqueued_jobs(only: DossierIndexSearchTermsJob) + it { expect(searching(dossier.id.to_s)).to eq([]) } end - let(:procedure_1) { create(:procedure, :published) } - let(:procedure_2) { create(:procedure, :published) } - - let(:dossier_0) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } - - let(:etablissement_1) { create(:etablissement, entreprise_raison_sociale: 'OCTO Academy', siret: '41636169600051') } - let(:dossier_1) { create(:dossier, :en_construction, procedure: procedure_1, user: create(:user, email: 'contact@test.com'), etablissement: etablissement_1) } + context 'with a dossier not in brouillon' do + let(:user) { create(:user, email: 'nicolas@email.com') } + let(:etablissement) { create(:etablissement, entreprise_raison_sociale: 'Direction Interministerielle Du Numérique', siret: '13002526500013') } + let(:dossier) do + create(:dossier, state: :en_construction, user:, etablissement:).tap do |dossier| + dossier.champs.first.update!(value: 'Hélène mange des pommes') + end + end - let(:etablissement_2) { create(:etablissement, entreprise_raison_sociale: 'Plop octo', siret: '41816602300012') } - let(:dossier_2) { create(:dossier, :en_construction, procedure: procedure_1, user: create(:user, email: 'plop@gmail.com'), etablissement: etablissement_2) } + it do + expect(searching('')).to eq([]) - let(:etablissement_3) { create(:etablissement, entreprise_raison_sociale: 'OCTO Technology', siret: '41816609600051') } - let(:dossier_3) { create(:dossier, :en_construction, procedure: procedure_2, user: create(:user, email: 'peace@clap.fr'), etablissement: etablissement_3) } + # by dossier id + expect(searching(dossier.id.to_s)).to eq([dossier.id]) - let(:dossier_archived) { create(:dossier, :en_construction, procedure: procedure_1, archived: true, user: create(:user, email: 'archived@clap.fr')) } + # by email + expect(searching('nicolas@email.com')).to eq([dossier.id]) + expect(searching('nicolas')).to eq([dossier.id]) - describe 'search is empty' do - let(:terms) { '' } + # by SIRET + expect(searching('13002526500013')).to eq([dossier.id]) + expect(searching('1300')).to eq([dossier.id]) - it { expect(subject.size).to eq(0) } - end + # by raison sociale + expect(searching('Direction Interministerielle Du Numérique')).to eq([dossier.id]) + expect(searching('Direction')).to eq([dossier.id]) - describe 'search brouillon file' do - let(:terms) { 'brouillon' } + # with multiple terms + expect(searching('Direction nicolas')).to eq([dossier.id]) - it { expect(subject.size).to eq(0) } - end + # with forbidden characters + expect(searching("'?\\:&!(Direction) ")).to eq([dossier.id]) - describe 'search archived file' do - let(:terms) { 'archived' } + # with supirious spaces + expect(searching(" nicolas ")).to eq([dossier.id]) - it { expect(subject.size).to eq(1) } - end + # with wrong case + expect(searching('direction')).to eq([dossier.id]) - describe 'search on contact email' do - let(:terms) { 'clap' } + # by champ text + expect(searching('Hélène')).to eq([dossier.id]) - it { expect(subject.size).to eq(0) } - end - - describe 'search on SIRET' do - context 'when is part of SIRET' do - let(:terms) { '4181' } - - it { expect(subject.size).to eq(1) } - end - - context 'when is a complet SIRET' do - let(:terms) { '41816602300012' } - - it { expect(subject.size).to eq(1) } + # by singular + expect(searching('la pomme')).to eq([dossier.id]) end end - describe 'search on raison social' do - let(:terms) { 'OCTO' } - - it { expect(subject.size).to eq(2) } - end + describe 'does not ignore archived dossiers' do + let(:dossier) { create(:dossier, state: :en_construction, archived: true) } - describe 'search terms surrounded with spurious spaces' do - let(:terms) { ' OCTO ' } - - it { expect(subject.size).to eq(2) } - end - - describe 'search on multiple fields' do - let(:terms) { 'octo plop' } - - it { expect(subject.size).to eq(1) } - end - - describe 'search with characters disallowed by the tsquery parser' do - let(:terms) { "'?\\:&!(OCTO) " } - - it { expect(subject.size).to eq(1) } + it { expect(searching(dossier.id.to_s)).to eq([dossier.id]) } end end From 06a71cdf8572bfb5d7f845dae8f601ab5ca326a6 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Dec 2024 12:49:25 +0100 Subject: [PATCH 3/8] search without accent --- app/services/dossier_search_service.rb | 4 ++-- spec/services/dossier_search_service_spec.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/services/dossier_search_service.rb b/app/services/dossier_search_service.rb index dc046ed92ba..5d4ad751517 100644 --- a/app/services/dossier_search_service.rb +++ b/app/services/dossier_search_service.rb @@ -27,8 +27,8 @@ def self.dossier_by_exact_id(dossiers, search_terms) end def self.dossier_by_full_text(dossiers, search_terms, with_annotations) - ts_vector = "to_tsvector('french', #{with_annotations ? 'dossiers.search_terms || dossiers.private_search_terms' : 'dossiers.search_terms'})" - ts_query = "to_tsquery('french', #{Dossier.connection.quote(to_tsquery(search_terms))})" + ts_vector = "to_tsvector('french', unaccent(#{with_annotations ? 'dossiers.search_terms || dossiers.private_search_terms' : 'dossiers.search_terms'}))" + ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))" dossiers .visible_by_administration diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index 0970862c812..d431080efc9 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -58,6 +58,9 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) # by singular expect(searching('la pomme')).to eq([dossier.id]) + + # without accent + expect(searching('helene')).to eq([dossier.id]) end end From 11402c6ee23dfca0808076f512c68fc8604b6855 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Dec 2024 15:33:11 +0100 Subject: [PATCH 4/8] clean unused includes --- app/services/dossier_search_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/dossier_search_service.rb b/app/services/dossier_search_service.rb index 5d4ad751517..d60eff5d0de 100644 --- a/app/services/dossier_search_service.rb +++ b/app/services/dossier_search_service.rb @@ -40,7 +40,7 @@ def self.dossier_by_full_text(dossiers, search_terms, with_annotations) def self.dossier_by_full_text_for_user(search_terms, dossiers) ts_vector = "to_tsvector('french', search_terms)" - ts_query = "to_tsquery('french', #{Dossier.includes(:procedure).connection.quote(to_tsquery(search_terms))})" + ts_query = "to_tsquery('french', #{Dossier.connection.quote(to_tsquery(search_terms))})" dossiers .visible_by_user From 6472d738d686c205c2e9d86a9913fabaeb0c485a Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Dec 2024 16:00:58 +0100 Subject: [PATCH 5/8] refactor mutualize complicated part of the search --- app/services/dossier_search_service.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/services/dossier_search_service.rb b/app/services/dossier_search_service.rb index d60eff5d0de..98bc3cdfa44 100644 --- a/app/services/dossier_search_service.rb +++ b/app/services/dossier_search_service.rb @@ -6,7 +6,7 @@ def self.matching_dossiers(dossiers, search_terms, with_annotations = false) [] else dossier_by_exact_id(dossiers, search_terms) - .presence || dossier_by_full_text(dossiers, search_terms, with_annotations) + .presence || dossier_ids_by_full_text(dossiers, search_terms, with_annotations) end end @@ -26,24 +26,25 @@ def self.dossier_by_exact_id(dossiers, search_terms) end end - def self.dossier_by_full_text(dossiers, search_terms, with_annotations) - ts_vector = "to_tsvector('french', unaccent(#{with_annotations ? 'dossiers.search_terms || dossiers.private_search_terms' : 'dossiers.search_terms'}))" - ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))" + def self.dossier_ids_by_full_text(dossiers, search_terms, with_annotations) + columns = with_annotations ? 'search_terms || private_search_terms' : 'search_terms' - dossiers - .visible_by_administration - .where("#{ts_vector} @@ #{ts_query}") - .order(Arel.sql("COALESCE(ts_rank(#{ts_vector}, #{ts_query}), 0) DESC")) + dossier_by_full_text(dossiers.visible_by_administration, columns, search_terms) .pluck('id') .uniq end def self.dossier_by_full_text_for_user(search_terms, dossiers) - ts_vector = "to_tsvector('french', search_terms)" - ts_query = "to_tsquery('french', #{Dossier.connection.quote(to_tsquery(search_terms))})" + columns = 'search_terms' + + dossier_by_full_text(dossiers.visible_by_user, columns, search_terms) + end + + def self.dossier_by_full_text(dossiers, columns, search_terms) + ts_vector = "to_tsvector('french', unaccent(#{columns}))" + ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))" dossiers - .visible_by_user .where("#{ts_vector} @@ #{ts_query}") .order(Arel.sql("COALESCE(ts_rank(#{ts_vector}, #{ts_query}), 0) DESC")) end From 08258630ed8922bed55cbe9f9cf5590399421c1c Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Dec 2024 16:24:41 +0100 Subject: [PATCH 6/8] clean dossier_search_service_spec matching_dossiers_for_user --- spec/services/dossier_search_service_spec.rb | 124 +++---------------- 1 file changed, 18 insertions(+), 106 deletions(-) diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index d431080efc9..f5827826d40 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -47,6 +47,9 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) # with forbidden characters expect(searching("'?\\:&!(Direction) ")).to eq([dossier.id]) + # with a single forbidden character should not crash postgres + expect(searching('? Direction')).to eq([dossier.id]) + # with supirious spaces expect(searching(" nicolas ")).to eq([dossier.id]) @@ -72,122 +75,31 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) end describe '#matching_dossiers_for_user' do - subject { liste_dossiers } - - before do - dossier_0 - dossier_0b - dossier_1 - dossier_2 - dossier_3 - dossier_archived - perform_enqueued_jobs(only: DossierIndexSearchTermsJob) - end - - let(:liste_dossiers) do - described_class.matching_dossiers_for_user(terms, user_1) - end - - let(:user_1) { create(:user, email: 'bidou@clap.fr') } - let(:user_2) { create(:user) } - - let(:procedure_1) { create(:procedure, :published) } - let(:procedure_2) { create(:procedure, :published) } - - let(:dossier_0) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure_1, user: user_1) } - let(:dossier_0b) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure_1, user: user_2) } - - let(:etablissement_1) { create(:etablissement, entreprise_raison_sociale: 'OCTO Academy', siret: '41636169600051') } - let(:dossier_1) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, user: user_1, etablissement: etablissement_1) } - - let(:etablissement_2) { create(:etablissement, entreprise_raison_sociale: 'Plop octo', siret: '41816602300012') } - let(:dossier_2) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, user: user_1, etablissement: etablissement_2) } - - let(:etablissement_3) { create(:etablissement, entreprise_raison_sociale: 'OCTO Technology', siret: '41816609600051') } - let(:dossier_3) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_2, user: user_1, etablissement: etablissement_3) } - - let(:dossier_archived) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, archived: true, user: user_1) } - - describe 'search is empty' do - let(:terms) { '' } - - it { expect(subject.size).to eq(0) } - end - - describe 'search by dossier id' do - context 'when the user owns the dossier' do - let(:terms) { dossier_0.id.to_s } - - it { expect(subject.map(&:id)).to include(dossier_0.id) } - end - - context 'when the user does not own the dossier' do - let(:terms) { dossier_0b.id.to_s } - - it { expect(subject.map(&:id)).not_to include(dossier_0b.id) } - end - end - - describe 'search brouillon file' do - let(:terms) { 'brouillon' } + let(:user) { create(:user) } + let(:another_user) { create(:user) } - it { expect(subject.size).to eq(0) } - end - - describe 'search on contact email' do - let(:terms) { 'bidou@clap.fr' } - - it { expect(subject.size).to eq(5) } - end - - describe 'search on contact name' do - let(:terms) { 'bidou@clap.fr' } - - it { expect(subject.size).to eq(5) } - end + before { perform_enqueued_jobs(only: DossierIndexSearchTermsJob) } - describe 'search on SIRET' do - context 'when is part of SIRET' do - let(:terms) { '4181' } + def searching(terms, user) = described_class.matching_dossiers_for_user(terms, user) - it { expect(subject.size).to eq(2) } - end + context 'when the dossier is brouillon' do + let(:dossier) { create(:dossier, state: :brouillon, user:) } - context 'when is a complet SIRET' do - let(:terms) { '41816602300012' } + it do + # searching its own dossier by id + expect(searching(dossier.id.to_s, user)).to eq([dossier]) - it { expect(subject.size).to eq(1) } + # searching another dossier by id + expect(searching(dossier.id.to_s, another_user)).to eq([]) end end - describe 'search on raison social' do - let(:terms) { 'OCTO' } - - it { expect(subject.size).to eq(3) } - end - - describe 'search terms surrounded with spurious spaces' do - let(:terms) { ' OCTO ' } - - it { expect(subject.size).to eq(3) } - end - - describe 'search on multiple fields' do - let(:terms) { 'octo plop' } - - it { expect(subject.size).to eq(1) } - end - - describe 'search with characters disallowed by the tsquery parser' do - let(:terms) { "'?\\:&!(OCTO) " } - - it { expect(subject.size).to eq(1) } - end + context 'when the user is invited on the dossier' do + let(:dossier) { create(:dossier) } - describe 'search with a single forbidden character should not crash postgres' do - let(:terms) { '? OCTO' } + before { create(:invite, dossier:, user:) } - it { expect(subject.size).to eq(3) } + it { expect(searching(dossier.id.to_s, user)).to eq([dossier]) } end end end From c6c82579b898df550f87922b25a47dafb294f342 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Dec 2024 17:18:34 +0100 Subject: [PATCH 7/8] current limit --- app/services/dossier_search_service.rb | 12 +++++------- spec/services/dossier_search_service_spec.rb | 4 ++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/services/dossier_search_service.rb b/app/services/dossier_search_service.rb index 98bc3cdfa44..17eecece429 100644 --- a/app/services/dossier_search_service.rb +++ b/app/services/dossier_search_service.rb @@ -27,20 +27,18 @@ def self.dossier_by_exact_id(dossiers, search_terms) end def self.dossier_ids_by_full_text(dossiers, search_terms, with_annotations) - columns = with_annotations ? 'search_terms || private_search_terms' : 'search_terms' - - dossier_by_full_text(dossiers.visible_by_administration, columns, search_terms) + dossier_by_full_text(dossiers.visible_by_administration, search_terms, with_annotations:) .pluck('id') .uniq end def self.dossier_by_full_text_for_user(search_terms, dossiers) - columns = 'search_terms' - - dossier_by_full_text(dossiers.visible_by_user, columns, search_terms) + dossier_by_full_text(dossiers.visible_by_user, search_terms) end - def self.dossier_by_full_text(dossiers, columns, search_terms) + def self.dossier_by_full_text(dossiers, search_terms, with_annotations: false) + columns = with_annotations ? 'search_terms || private_search_terms' : 'search_terms' + ts_vector = "to_tsvector('french', unaccent(#{columns}))" ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))" diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index f5827826d40..3c068b640f2 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -64,6 +64,10 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) # without accent expect(searching('helene')).to eq([dossier.id]) + + # NOT WORKING YET + # with a single faulty character + expect(searching('des pammes')).to eq([]) end end From cf705813da58311e1045de28c201f01a1d866da6 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 4 Dec 2024 19:02:53 +0100 Subject: [PATCH 8/8] fix and spec for annotations search --- app/services/dossier_search_service.rb | 2 +- spec/services/dossier_search_service_spec.rb | 25 ++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/services/dossier_search_service.rb b/app/services/dossier_search_service.rb index 17eecece429..05aba219968 100644 --- a/app/services/dossier_search_service.rb +++ b/app/services/dossier_search_service.rb @@ -37,7 +37,7 @@ def self.dossier_by_full_text_for_user(search_terms, dossiers) end def self.dossier_by_full_text(dossiers, search_terms, with_annotations: false) - columns = with_annotations ? 'search_terms || private_search_terms' : 'search_terms' + columns = with_annotations ? 'search_terms || \' \' || private_search_terms' : 'search_terms' ts_vector = "to_tsvector('french', unaccent(#{columns}))" ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))" diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index 3c068b640f2..f7e5ed2fd1d 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -6,7 +6,9 @@ before { perform_enqueued_jobs(only: DossierIndexSearchTermsJob) } - def searching(terms) = described_class.matching_dossiers(dossiers, terms) + def searching(terms, with_annotations: false) + described_class.matching_dossiers(dossiers, terms, with_annotations) + end describe 'ignores brouillon' do let(:dossier) { create(:dossier, state: :brouillon) } @@ -17,9 +19,11 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) context 'with a dossier not in brouillon' do let(:user) { create(:user, email: 'nicolas@email.com') } let(:etablissement) { create(:etablissement, entreprise_raison_sociale: 'Direction Interministerielle Du Numérique', siret: '13002526500013') } + let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :text }], types_de_champ_private: [{ type: :text }]) } let(:dossier) do - create(:dossier, state: :en_construction, user:, etablissement:).tap do |dossier| - dossier.champs.first.update!(value: 'Hélène mange des pommes') + create(:dossier, procedure:, state: :en_construction, user:, etablissement:).tap do |dossier| + dossier.project_champs_public.first.update!(value: 'Hélène mange des pommes') + dossier.project_champs_private.first.update!(value: 'annotations') end end @@ -29,6 +33,11 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) # by dossier id expect(searching(dossier.id.to_s)).to eq([dossier.id]) + # annotations is unsearchable by default + expect(searching('annotations')).to eq([]) + # but can be searched with the with_annotations option + expect(searching('annotations', with_annotations: true)).to eq([dossier.id]) + # by email expect(searching('nicolas@email.com')).to eq([dossier.id]) expect(searching('nicolas')).to eq([dossier.id]) @@ -87,7 +96,12 @@ def searching(terms) = described_class.matching_dossiers(dossiers, terms) def searching(terms, user) = described_class.matching_dossiers_for_user(terms, user) context 'when the dossier is brouillon' do - let(:dossier) { create(:dossier, state: :brouillon, user:) } + let(:procedure) { create(:procedure, types_de_champ_private: [{ type: :text }]) } + let(:dossier) do + create(:dossier, procedure:, state: :brouillon, user:).tap do |dossier| + dossier.project_champs_private.first.update!(value: 'annotations') + end + end it do # searching its own dossier by id @@ -95,6 +109,9 @@ def searching(terms, user) = described_class.matching_dossiers_for_user(terms, u # searching another dossier by id expect(searching(dossier.id.to_s, another_user)).to eq([]) + + # annotations is unsearchable + expect(searching('annotations', user)).to eq([]) end end