fix(user dossiers index): do not crash with a deleted dossier and a discarded procedure
This commit is contained in:
parent
e2d7be215e
commit
44859b8217
3 changed files with 14 additions and 4 deletions
|
@ -27,7 +27,7 @@ module Users
|
||||||
@dossiers_traites = current_user.dossiers.state_termine.merge(dossiers_visibles)
|
@dossiers_traites = current_user.dossiers.state_termine.merge(dossiers_visibles)
|
||||||
@dossiers_invites = current_user.dossiers_invites.merge(dossiers_visibles)
|
@dossiers_invites = current_user.dossiers_invites.merge(dossiers_visibles)
|
||||||
@dossiers_supprimes_recemment = current_user.dossiers.hidden_by_user.merge(dossiers)
|
@dossiers_supprimes_recemment = current_user.dossiers.hidden_by_user.merge(dossiers)
|
||||||
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.order_by_updated_at
|
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.includes(:procedure).order_by_updated_at
|
||||||
@dossier_transfers = DossierTransfer.for_email(current_user.email)
|
@dossier_transfers = DossierTransfer.for_email(current_user.email)
|
||||||
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.merge(dossiers_visibles)
|
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.merge(dossiers_visibles)
|
||||||
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
|
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
|
||||||
|
|
|
@ -13,14 +13,12 @@
|
||||||
%th Date de suppression
|
%th Date de suppression
|
||||||
%tbody
|
%tbody
|
||||||
- deleted_dossiers.each do |dossier|
|
- deleted_dossiers.each do |dossier|
|
||||||
- libelle_demarche = Procedure.find(dossier.procedure_id).libelle
|
|
||||||
|
|
||||||
%tr{ data: { 'dossier-id': dossier.dossier_id } }
|
%tr{ data: { 'dossier-id': dossier.dossier_id } }
|
||||||
%td.number-col
|
%td.number-col
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
= dossier.dossier_id
|
= dossier.dossier_id
|
||||||
%td
|
%td
|
||||||
= libelle_demarche
|
= dossier.procedure.libelle
|
||||||
|
|
||||||
%td.cell-link
|
%td.cell-link
|
||||||
= deletion_reason_badge(dossier.reason)
|
= deletion_reason_badge(dossier.reason)
|
||||||
|
|
|
@ -913,6 +913,18 @@ describe Users::DossiersController, type: :controller do
|
||||||
expect(assigns(:dossiers_invites).second.updated_at.to_date).to eq(4.days.ago.to_date)
|
expect(assigns(:dossiers_invites).second.updated_at.to_date).to eq(4.days.ago.to_date)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the user has a deleted dossier on a discarded procedure' do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
let!(:deleted_dossier) { create(:deleted_dossier, user_id: user.id) }
|
||||||
|
|
||||||
|
before { deleted_dossier.procedure.discard! }
|
||||||
|
|
||||||
|
subject { get(:index, params: { statut: 'dossiers-supprimes-definitivement' }) }
|
||||||
|
|
||||||
|
it { is_expected.to have_http_status(200) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
|
|
Loading…
Reference in a new issue