[fix #997] New Style: allow new line in messagerie
This commit is contained in:
parent
2a5f92ffaf
commit
bbcf350d7d
3 changed files with 14 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
module NewGestionnaire
|
||||
class DossiersController < ProceduresController
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
def attestation
|
||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||
end
|
||||
|
@ -51,7 +53,15 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def create_commentaire
|
||||
@commentaire = Commentaire.new(commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier))
|
||||
commentaire_hash = commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier)
|
||||
|
||||
# avoid simple_format replacing '' by '<p></p>'
|
||||
# and thus skipping the not empty constraint on commentaire's body
|
||||
if commentaire_hash[:body].present?
|
||||
commentaire_hash[:body] = simple_format(commentaire_hash[:body])
|
||||
end
|
||||
|
||||
@commentaire = Commentaire.new(commentaire_hash)
|
||||
|
||||
if @commentaire.save
|
||||
current_gestionnaire.follow(dossier)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
- 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')
|
||||
%p.rich-text= sanitize(commentaire.body)
|
||||
.rich-text= sanitize(commentaire.body)
|
||||
|
||||
- if commentaire.file.present?
|
||||
.attachment-link
|
||||
|
|
|
@ -111,7 +111,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
|
||||
describe "#create_commentaire" do
|
||||
let(:saved_commentaire) { dossier.commentaires.first }
|
||||
let(:body) { "body" }
|
||||
let(:body) { "avant\napres" }
|
||||
let(:file) { nil }
|
||||
let(:scan_result) { true }
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it do
|
||||
subject
|
||||
|
||||
expect(saved_commentaire.body).to eq('body')
|
||||
expect(saved_commentaire.body).to eq("<p>avant\n<br />apres</p>")
|
||||
expect(saved_commentaire.email).to eq(gestionnaire.email)
|
||||
expect(saved_commentaire.dossier).to eq(dossier)
|
||||
expect(response).to redirect_to(messagerie_dossier_path(dossier.procedure, dossier))
|
||||
|
|
Loading…
Reference in a new issue