Merge pull request #10535 from mfo/US/page-procedure-show

Améliroation, ETQ instructeur le nombre de dossier par page passe de 25 a 100
This commit is contained in:
Colin Darie 2024-06-24 08:14:56 +00:00 committed by GitHub
commit 5ac2315b5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View file

@ -3,7 +3,7 @@ module Instructeurs
before_action :ensure_ownership!, except: [:index] before_action :ensure_ownership!, except: [:index]
before_action :ensure_not_super_admin!, only: [:download_export, :exports] before_action :ensure_not_super_admin!, only: [:download_export, :exports]
ITEMS_PER_PAGE = 25 ITEMS_PER_PAGE = 100
BATCH_SELECTION_LIMIT = 500 BATCH_SELECTION_LIMIT = 500
def index def index

View file

@ -330,6 +330,32 @@ describe Instructeurs::ProceduresController, type: :controller do
it { expect(assigns(:filtered_sorted_paginated_ids)).to match_array([new_unfollow_dossier].map(&:id)) } it { expect(assigns(:filtered_sorted_paginated_ids)).to match_array([new_unfollow_dossier].map(&:id)) }
end end
context 'with pagination' do
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_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
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
context 'with a dossier en contruction hidden by user' do context 'with a dossier en contruction hidden by user' do
let!(:hidden_dossier) { create(:dossier, :en_construction, groupe_instructeur: gi_2, hidden_by_user_at: 1.hour.ago) } let!(:hidden_dossier) { create(:dossier, :en_construction, groupe_instructeur: gi_2, hidden_by_user_at: 1.hour.ago) }
before { subject } before { subject }