Merge pull request #3744 from betagouv/avis-newlines

Respecte les sauts de lignes dans les avis
This commit is contained in:
Paul Chavard 2019-04-04 10:31:12 +02:00 committed by GitHub
commit c4ef6d89c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 7 deletions

View file

@ -105,6 +105,10 @@
margin-top: $default-padding;
}
.answer-body p:not(:last-of-type) {
margin-bottom: $default-padding;
}
.avis-icon {
margin-right: $default-spacer;
}

View file

@ -29,4 +29,5 @@
- else
%span.waiting En attente de réponse
= render partial: 'shared/piece_jointe/pj_link', locals: { object: avis, pj: avis.piece_justificative_file }
%p= avis.answer
.answer-body
= simple_format(avis.answer)

View file

@ -19,5 +19,9 @@ FactoryBot.define do
avis.claimant = create :gestionnaire
end
end
trait :with_answer do
answer { "Mon avis se décompose en deux points :\n- La demande semble pertinente\n- Le demandeur remplit les conditions." }
end
end
end

View file

@ -1,3 +1,5 @@
require 'spec_helper'
describe 'gestionnaires/shared/avis/_list.html.haml', type: :view do
before { view.extend DossierHelper }
@ -5,16 +7,22 @@ describe 'gestionnaires/shared/avis/_list.html.haml', type: :view do
let(:gestionnaire) { create(:gestionnaire) }
let(:avis) { [create(:avis, claimant: gestionnaire)] }
let(:seen_at) { avis.first.created_at + 1.hour }
context "with a seen_at after avis created_at" do
let(:seen_at) { avis.first.created_at + 1.hour }
it { is_expected.to have_text(avis.first.introduction) }
it { is_expected.not_to have_css(".highlighted") }
it { is_expected.not_to have_css(".highlighted") }
end
context "with a seen_at after avis created_at" do
context 'with a seen_at before avis created_at' do
let(:seen_at) { avis.first.created_at - 1.hour }
it { is_expected.to have_css(".highlighted") }
end
context 'with an answer' do
let(:avis) { [create(:avis, :with_answer, claimant: gestionnaire)] }
it 'renders the answer formatted with newlines' do
expect(subject).to include(simple_format(avis.first.answer))
end
end
end