feat(gallery): add pjs from messagerie to gallery
This commit is contained in:
parent
b66d83ab08
commit
59ddaf5b0b
2 changed files with 45 additions and 3 deletions
|
@ -34,3 +34,33 @@
|
|||
.champ-libelle
|
||||
= champ.libelle.truncate(25)
|
||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||
|
||||
- @dossier.commentaires.map(&:piece_jointe).map(&:attachments).flatten.each do |attachment|
|
||||
.gallery-item
|
||||
- blob = attachment.blob
|
||||
- if displayable_pdf?(blob)
|
||||
= link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "Messagerie -- #{blob.filename}" do
|
||||
.thumbnail
|
||||
= image_tag(preview_url_for(attachment), loading: :lazy)
|
||||
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
||||
Visualiser
|
||||
.champ-libelle
|
||||
Messagerie
|
||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||
|
||||
- elsif displayable_image?(blob)
|
||||
= link_to image_url(blob_url(attachment)), title: "Messagerie -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
|
||||
.thumbnail
|
||||
= image_tag(variant_url_for(attachment), loading: :lazy)
|
||||
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
||||
Visualiser
|
||||
.champ-libelle
|
||||
Messagerie
|
||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||
|
||||
- else
|
||||
.thumbnail
|
||||
= image_tag('apercu-indisponible.png')
|
||||
.champ-libelle
|
||||
Messagerie
|
||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||
|
|
|
@ -1399,25 +1399,37 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
describe '#pieces_jointes' do
|
||||
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }], instructeurs:) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure: procedure) }
|
||||
let(:path) { 'spec/fixtures/files/logo_test_procedure.png' }
|
||||
let(:logo_path) { 'spec/fixtures/files/logo_test_procedure.png' }
|
||||
let(:rib_path) { 'spec/fixtures/files/RIB.pdf' }
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
||||
|
||||
before do
|
||||
dossier.champs.first.piece_justificative_file.attach(
|
||||
io: File.open(path),
|
||||
io: File.open(logo_path),
|
||||
filename: "logo_test_procedure.png",
|
||||
content_type: "image/png",
|
||||
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
|
||||
)
|
||||
|
||||
commentaire.piece_jointe.attach(
|
||||
io: File.open(rib_path),
|
||||
filename: "RIB.pdf",
|
||||
content_type: "application/pdf",
|
||||
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
|
||||
)
|
||||
|
||||
get :pieces_jointes, params: {
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id
|
||||
}
|
||||
end
|
||||
|
||||
it do
|
||||
it 'returns pieces jointes from champs and from messagerie' do
|
||||
expect(response.body).to include('Télécharger le fichier toto.txt')
|
||||
expect(response.body).to include('Télécharger le fichier logo_test_procedure.png')
|
||||
expect(response.body).to include('Télécharger le fichier RIB.pdf')
|
||||
expect(response.body).to include('Visualiser')
|
||||
expect(assigns(:attachments_and_libelles).count).to eq 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue