[Fix #888] New UI : Add upload on commentaire form
This commit is contained in:
parent
5775901868
commit
ae5e6653cb
3 changed files with 26 additions and 7 deletions
|
@ -99,7 +99,7 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def commentaire_params
|
||||
params.require(:commentaire).permit(:body)
|
||||
params.require(:commentaire).permit(:body, :file)
|
||||
end
|
||||
|
||||
def avis_params
|
||||
|
|
|
@ -15,15 +15,21 @@
|
|||
- if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email)
|
||||
%span.guest Invité
|
||||
%span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y')
|
||||
.rich-text
|
||||
= sanitize(commentaire.body)
|
||||
- if file = commentaire.piece_justificative
|
||||
%p.rich-text= sanitize(commentaire.body)
|
||||
|
||||
- if commentaire.file.present?
|
||||
.attachment-link
|
||||
= link_to file.content_url, class: "button", target: "_blank", title: "Télécharger" do
|
||||
= link_to commentaire.file.url, class: "button", target: "_blank", title: "Télécharger" do
|
||||
.icon.attachment
|
||||
= file.original_filename
|
||||
= commentaire.file_identifier
|
||||
- elsif commentaire.piece_justificative
|
||||
.attachment-link
|
||||
= link_to commentaire.piece_justificative.content_url, class: "button", target: "_blank", title: "Télécharger" do
|
||||
.icon.attachment
|
||||
= commentaire.piece_justificative.original_filename
|
||||
|
||||
= form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f|
|
||||
= f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true
|
||||
= f.file_field :file
|
||||
.send-wrapper
|
||||
= f.submit 'Envoyer', class: 'button send', data: { disable_with: "Envoi..." }
|
||||
|
|
|
@ -111,12 +111,18 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
|
||||
describe "#create_commentaire" do
|
||||
let(:saved_commentaire) { dossier.commentaires.first }
|
||||
let(:file) { nil }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
||||
|
||||
post :create_commentaire, params: {
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id,
|
||||
commentaire: { body: 'body' }
|
||||
commentaire: {
|
||||
body: 'body',
|
||||
file: file
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -125,6 +131,13 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it { expect(saved_commentaire.dossier).to eq(dossier) }
|
||||
it { expect(response).to redirect_to(messagerie_dossier_path(dossier.procedure, dossier)) }
|
||||
it { expect(gestionnaire.followed_dossiers).to include(dossier) }
|
||||
it { expect(saved_commentaire.file.present?).to eq(false) }
|
||||
|
||||
context "with a file" do
|
||||
let(:file) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') }
|
||||
|
||||
it { expect(saved_commentaire.file.present?).to eq(true) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create_avis" do
|
||||
|
|
Loading…
Reference in a new issue