feat(gallery): add attachments from avis

This commit is contained in:
Eric Leroy-Terquem 2024-10-09 17:41:46 +02:00
parent e95e86faae
commit d10df6e17c
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
5 changed files with 99 additions and 8 deletions

View file

@ -101,4 +101,52 @@ RSpec.describe Attachment::GalleryItemComponent, type: :component do
end
end
end
context "when attachment is from an avis" do
context 'from an instructeur' do
let(:avis) { create(:avis, :with_introduction, dossier: dossier) }
let(:attachment) { avis.introduction_file.attachment }
it "displays a generic libelle, link, tag and renders title" do
expect(subject).to have_text('Pièce jointe à lavis')
expect(subject).to have_link(filename)
expect(subject).to have_text('Avis externe (instructeur)')
expect(component.title).to eq("Pièce jointe à lavis -- #{filename}")
end
context "when instructeur has not seen it yet" do
let(:seen_at) { now - 1.day }
before do
attachment.blob.update(created_at: now)
end
it 'displays datetime in the right style' do
expect(subject).to have_css('.highlighted')
end
end
context "when instructeur has already seen it" do
let!(:seen_at) { now }
before do
freeze_time
attachment.blob.touch(:created_at)
end
it 'displays datetime in the right style' do
expect(subject).not_to have_css('.highlighted')
end
end
end
context 'from an expert' do
let(:avis) { create(:avis, :with_piece_justificative, dossier: dossier) }
let(:attachment) { avis.piece_justificative_file.attachment }
it "displays the right tag" do
expect(subject).to have_text('Avis externe (expert)')
end
end
end
end