diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 386114576..2b8702cf3 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -3,7 +3,7 @@ module Instructeurs before_action :ensure_ownership!, except: [:index] before_action :ensure_not_super_admin!, only: [:download_export, :exports] - ITEMS_PER_PAGE = 25 + ITEMS_PER_PAGE = 100 BATCH_SELECTION_LIMIT = 500 def index diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index 93f13fdbd..8aad3822d 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -331,16 +331,28 @@ describe Instructeurs::ProceduresController, type: :controller do end context 'with pagination' do - let(:dossiers) { 26.times.map { create(:dossier, :en_instruction, procedure: procedure) } } - before { dossiers } + let(:dossiers) { Array.new(26) { create(:dossier, :en_instruction, procedure: procedure) } } + before do # warmup cache + get :show, params: { procedure_id: procedure.id, statut: statut } + dossiers + end + it 'keeps request count stable' do - count = 0 - callback = lambda { |*_args| count += 1 } - ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do - subject + count_with_25, count_with_100 = 0, 0 + + stub_const('Instructeurs::ProceduresController::ITEMS_PER_PAGE', 25) + ActiveSupport::Notifications.subscribed(lambda { |*_args| count_with_25 += 1 }, "sql.active_record") do + get :show, params: { procedure_id: procedure.id, statut: statut } expect(assigns(:projected_dossiers).size).to eq(25) end - expect(count).to eq(43) + + stub_const('Instructeurs::ProceduresController::ITEMS_PER_PAGE', 100) + ActiveSupport::Notifications.subscribed(lambda { |*_args| count_with_100 += 1 }, "sql.active_record") do + get :show, params: { procedure_id: procedure.id, statut: statut } + expect(assigns(:projected_dossiers).size).to eq(dossiers.size + 1) # +1 due to let!(:new_unfollow_dossier) + end + + expect(count_with_100).to eq(count_with_25) end end