feat(gallery): add attachments from commentaires from experts
This commit is contained in:
parent
ad98bafeca
commit
2e2d2afecb
3 changed files with 20 additions and 2 deletions
|
@ -30,6 +30,8 @@ class Attachment::GalleryItemComponent < ApplicationComponent
|
|||
case
|
||||
when from_dossier?
|
||||
'Dossier usager'
|
||||
when from_messagerie_expert?
|
||||
'Messagerie (expert)'
|
||||
when from_messagerie_instructeur?
|
||||
'Messagerie (instructeur)'
|
||||
when from_messagerie_usager?
|
||||
|
@ -90,8 +92,12 @@ class Attachment::GalleryItemComponent < ApplicationComponent
|
|||
from_messagerie? && attachment.record.instructeur.present?
|
||||
end
|
||||
|
||||
def from_messagerie_expert?
|
||||
from_messagerie? && attachment.record.expert.present?
|
||||
end
|
||||
|
||||
def from_messagerie_usager?
|
||||
from_messagerie? && attachment.record.instructeur.nil?
|
||||
from_messagerie? && attachment.record.instructeur.nil? && attachment.record.expert.nil?
|
||||
end
|
||||
|
||||
def from_avis_externe?
|
||||
|
|
|
@ -167,7 +167,11 @@ module Experts
|
|||
@commentaire = CommentaireService.create(current_expert, avis.dossier, commentaire_params)
|
||||
|
||||
if @commentaire.errors.empty?
|
||||
@commentaire.dossier.update!(last_commentaire_updated_at: Time.zone.now)
|
||||
timestamps = [:last_commentaire_updated_at, :updated_at]
|
||||
timestamps << :last_commentaire_piece_jointe_updated_at if @commentaire.piece_jointe.attached?
|
||||
|
||||
@commentaire.dossier.touch(*timestamps)
|
||||
|
||||
flash.notice = "Message envoyé"
|
||||
redirect_to messagerie_expert_avis_path(avis.procedure, avis)
|
||||
else
|
||||
|
|
|
@ -100,6 +100,14 @@ RSpec.describe Attachment::GalleryItemComponent, type: :component do
|
|||
expect(subject).to have_text('Messagerie (instructeur)')
|
||||
end
|
||||
end
|
||||
|
||||
context 'from an expert' do
|
||||
let(:expert) { create(:expert) }
|
||||
before { commentaire.update!(expert:) }
|
||||
it "displays the right tag" do
|
||||
expect(subject).to have_text('Messagerie (expert)')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when attachment is from an avis" do
|
||||
|
|
Loading…
Reference in a new issue