diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 92f4d00a8..1b9e1c05c 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -296,6 +296,8 @@ module Users @dossier = dossier_with_champs(pj_template: false) @errors = update_dossier_and_compute_errors + @dossier.index_search_terms_later if @errors.empty? + respond_to do |format| format.turbo_stream do @to_show, @to_hide, @to_update = champs_to_turbo_update(champs_public_attributes_params, dossier.champs.filter(&:public?)) diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index ad99422a4..e0fd3501e 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -770,6 +770,16 @@ describe Users::DossiersController, type: :controller do end end end + + it "debounce search terms indexation" do + # dossier creation trigger a first indexation and flag, + # so we we have to remove this flag + dossier.debounce_index_search_terms_flag.remove + + assert_enqueued_jobs(1, only: DossierIndexSearchTermsJob) do + 3.times { patch :update, params: payload, format: :turbo_stream } + end + end end describe '#update en_construction' do