feat(gallery): add origin tag to gallery item

This commit is contained in:
Eric Leroy-Terquem 2024-09-10 11:43:25 +02:00
parent df08617387
commit bc237152e7
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
3 changed files with 49 additions and 7 deletions

View file

@ -3,6 +3,7 @@
require 'rails_helper'
RSpec.describe Attachment::GalleryItemComponent, type: :component do
let(:instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure, :published, types_de_champ_public:) }
let(:types_de_champ_public) { [{ type: :piece_justificative }] }
let(:dossier) { create(:dossier, :with_populated_champs, :en_construction, procedure:) }
@ -18,10 +19,11 @@ RSpec.describe Attachment::GalleryItemComponent, type: :component do
let(:libelle) { champ.libelle }
let(:attachment) { champ.piece_justificative_file.attachments.first }
it "displays libelle, link and renders title" do
it "displays libelle, link, tag and renders title" do
expect(subject).to have_text(libelle)
expect(subject).not_to have_text('Pièce jointe au message')
expect(subject).to have_link(filename)
expect(subject).to have_text('Dossier usager')
expect(component.title).to eq("#{libelle} -- #{filename}")
end
@ -42,10 +44,20 @@ RSpec.describe Attachment::GalleryItemComponent, type: :component do
let(:commentaire) { create(:commentaire, :with_file, dossier: dossier) }
let(:attachment) { commentaire.piece_jointe.first }
it "displays a generic libelle, link and renders title" do
expect(subject).to have_text('Pièce jointe au message')
expect(subject).to have_link(filename)
expect(component.title).to eq("Pièce jointe au message -- #{filename}")
context 'from an usager' do
it "displays a generic libelle, link, tag and renders title" do
expect(subject).to have_text('Pièce jointe au message')
expect(subject).to have_link(filename)
expect(subject).to have_text('Messagerie (usager)')
expect(component.title).to eq("Pièce jointe au message -- #{filename}")
end
end
context 'from an instructeur' do
before { commentaire.update!(instructeur:) }
it "displays the right tag" do
expect(subject).to have_text('Messagerie (instructeur)')
end
end
end
end