fix multiple errors from creation of dedicated method to restore and extend
This commit is contained in:
parent
4b1e743ecf
commit
4f7b0c93d0
5 changed files with 10 additions and 6 deletions
|
@ -25,6 +25,8 @@ module Instructeurs
|
|||
|
||||
def extend_conservation_and_restore
|
||||
dossier.extend_conservation_and_restore(1.month, current_instructeur)
|
||||
flash[:notice] = t('views.instructeurs.dossiers.archived_dossier')
|
||||
redirect_back(fallback_location: instructeur_dossier_path(@dossier.procedure, @dossier))
|
||||
end
|
||||
|
||||
def geo_data
|
||||
|
@ -380,7 +382,7 @@ module Instructeurs
|
|||
Dossier
|
||||
.where(id: current_instructeur.dossiers.visible_by_administration)
|
||||
.or(Dossier.where(id: current_user.dossiers.for_procedure_preview))
|
||||
elsif action_name == 'extend_conservation'
|
||||
elsif action_name == 'extend_conservation_and_restore'
|
||||
Dossier
|
||||
.where(id: current_instructeur.dossiers.visible_by_administration)
|
||||
.or(Dossier.where(id: current_instructeur.dossiers.hidden_by_expired))
|
||||
|
|
|
@ -260,7 +260,9 @@ module Users
|
|||
end
|
||||
|
||||
def extend_conservation_and_restore
|
||||
dossier.extend_conservation_and_restore(conservation_extension, author)
|
||||
dossier.extend_conservation_and_restore(dossier.procedure.duree_conservation_dossiers_dans_ds.months, current_user)
|
||||
flash[:notice] = t('views.users.dossiers.archived_dossier', duree_conservation_dossiers_dans_ds: dossier.procedure.duree_conservation_dossiers_dans_ds)
|
||||
redirect_back(fallback_location: dossier_path(@dossier))
|
||||
end
|
||||
|
||||
def modifier
|
||||
|
@ -534,7 +536,7 @@ module Users
|
|||
Dossier.visible_by_user.or(Dossier.for_procedure_preview).or(Dossier.for_editing_fork)
|
||||
elsif action_name == 'restore'
|
||||
Dossier.hidden_by_user
|
||||
elsif action_name == 'extend_conservation'
|
||||
elsif action_name == 'extend_conservation_and_restore'
|
||||
Dossier.visible_by_user.or(Dossier.hidden_by_expired)
|
||||
else
|
||||
Dossier.visible_by_user
|
||||
|
|
|
@ -691,7 +691,7 @@ class Dossier < ApplicationRecord
|
|||
def extend_conservation_and_restore(conservation_extension, author)
|
||||
extend_conservation(conservation_extension)
|
||||
update(hidden_by_expired_at: nil, hidden_by_reason: nil)
|
||||
restore(current_user)
|
||||
restore(author)
|
||||
end
|
||||
|
||||
def show_procedure_state_warning?
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
|
||||
- else
|
||||
- if dossier.expiration_can_be_extended?
|
||||
= button_to users_dossier_extend_conservation_and_restore_path(dossier), class: 'fr-btn fr-btn--sm' do
|
||||
= button_to users_dossier_repousser_expiration_and_restore_path(dossier), class: 'fr-btn fr-btn--sm' do
|
||||
Restaurer et étendre la conservation
|
||||
|
||||
|
||||
|
|
|
@ -1308,7 +1308,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#extend_conservation and restore' do
|
||||
subject { post :extend_conservation, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
subject { post :extend_conservation_and_restore, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
|
||||
before do
|
||||
dossier.update(hidden_by_expired_at: 1.hour.ago, hidden_by_reason: 'expired')
|
||||
|
|
Loading…
Reference in a new issue