fix(expert.attestation.url): was pointing to attestation_instructeur_dossier_path, so did not worked when expert was not instructeur. use active_storage_link, secured enough because served to authenticated users as well as expiring link

This commit is contained in:
Martin 2024-03-29 17:22:40 +01:00 committed by Martin
parent 46c5830306
commit 2944a0c2c3
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
7 changed files with 6 additions and 20 deletions

View file

@ -17,12 +17,6 @@ module Instructeurs
after_action :mark_avis_as_read, only: [:avis, :create_avis]
after_action :mark_annotations_privees_as_read, only: [:annotations_privees, :update_annotations]
def attestation
if dossier.attestation.pdf.attached?
redirect_to dossier.attestation.pdf.url, allow_other_host: true
end
end
def extend_conservation
dossier.extend_conservation(1.month)
flash[:notice] = t('views.instructeurs.dossiers.archived_dossier')

View file

@ -23,4 +23,4 @@
- if dossier.attestation.present?
= render Dossiers::RowShowComponent.new(label: "Attestation") do |c|
- c.with_value do
= link_to('Voir lattestation', attestation_instructeur_dossier_path(dossier.procedure, dossier), **external_link_attributes)
= render Dsfr::DownloadComponent.new(attachment: dossier.attestation.pdf, name: t(:download_attestation, scope: [:views, :shared, :dossiers, :form]))

View file

@ -346,6 +346,7 @@ en:
form:
submitted_at: "Submitted on %{datetime}"
updated_at: "Updated on %{datetime}"
download_attestation: "Download attestation"
edit:
autosave: Your file is automatically saved after each modification. You can close the window at any time and pick up where you left off later.
messages:

View file

@ -348,6 +348,7 @@ fr:
form:
submitted_at: "Déposé le %{datetime}"
updated_at: "Modifié le %{datetime}"
download_attestation: "Télécharger lattestation"
edit:
autosave: Votre dossier est enregistré automatiquement après chaque modification. Vous pouvez à tout moment fermer la fenêtre et reprendre plus tard là où vous en étiez.
messages:

View file

@ -475,7 +475,6 @@ Rails.application.routes.draw do
member do
resources :commentaires, only: [:destroy]
post 'repousser-expiration' => 'dossiers#extend_conservation'
get 'attestation'
get 'geo_data'
get 'apercu_attestation'
get 'bilans_bdf'

View file

@ -13,17 +13,6 @@ describe Instructeurs::DossiersController, type: :controller do
before { sign_in(instructeur.user) }
describe '#attestation' do
context 'when a dossier has an attestation' do
let(:dossier) { create(:dossier, :accepte, attestation: create(:attestation, :with_pdf), procedure: procedure) }
it 'redirects to a service tmp_url' do
get :attestation, params: { procedure_id: procedure.id, dossier_id: dossier.id }
expect(response.location).to match '/rails/active_storage/disk/'
end
end
end
describe '#send_to_instructeurs' do
let(:mail) { double("mail") }

View file

@ -35,8 +35,10 @@ describe 'instructeurs/dossiers/show', type: :view do
let(:dossier) { create :dossier, :accepte, :with_attestation }
it 'provides a link to the attestation' do
pdf = dossier.attestation.pdf
expect(dossier).to receive(:attestation).and_return(double(pdf: pdf)).at_least(2)
expect(subject).to have_text('Attestation')
expect(subject).to have_link(href: attestation_instructeur_dossier_path(dossier.procedure, dossier))
expect(subject).to have_text("Télécharger lattestation")
end
end