Skip to content

Commit

Permalink
fix multiple errors from creation of dedicated method to restore and …
Browse files Browse the repository at this point in the history
…extend
  • Loading branch information
lisa-durand committed Jul 25, 2024
1 parent 4b1e743 commit 1d50953
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/controllers/instructeurs/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def extend_conservation

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))

Check warning on line 29 in app/controllers/instructeurs/dossiers_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/instructeurs/dossiers_controller.rb#L27-L29

Added lines #L27 - L29 were not covered by tests
end

def geo_data
Expand Down Expand Up @@ -380,7 +382,7 @@ def dossier_scope
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))
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ def extend_conservation
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))

Check warning on line 265 in app/controllers/users/dossiers_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/users/dossiers_controller.rb#L263-L265

Added lines #L263 - L265 were not covered by tests
end

def modifier
Expand Down Expand Up @@ -534,7 +536,7 @@ def dossier_scope
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' || action_name == 'extend_conservation_and_restore'
Dossier.visible_by_user.or(Dossier.hidden_by_expired)
else
Dossier.visible_by_user
Expand Down
2 changes: 1 addition & 1 deletion app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def extend_conservation(conservation_extension)
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)

Check warning on line 694 in app/models/dossier.rb

View check run for this annotation

Codecov / codecov/patch

app/models/dossier.rb#L692-L694

Added lines #L692 - L694 were not covered by tests
end

def show_procedure_state_warning?
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/dossiers/_dossiers_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/instructeurs/dossiers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@
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')
Expand Down

0 comments on commit 1d50953

Please sign in to comment.