2023-03-06 15:51:08 +01:00
|
|
|
|
describe 'shared/avis/_list', type: :view do
|
2017-12-07 11:15:51 +01:00
|
|
|
|
before { view.extend DossierHelper }
|
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
|
subject { render 'shared/avis/list', avis: avis, avis_seen_at: seen_at, expert_or_instructeur: instructeur }
|
2017-12-07 11:15:51 +01:00
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
|
let(:instructeur) { create(:instructeur) }
|
2021-11-29 16:27:54 +01:00
|
|
|
|
let(:instructeur2) { create(:instructeur) }
|
|
|
|
|
let(:introduction_file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
|
2021-02-28 22:20:24 +01:00
|
|
|
|
let(:expert) { create(:expert) }
|
|
|
|
|
let!(:dossier) { create(:dossier) }
|
2021-03-23 12:25:57 +01:00
|
|
|
|
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure) }
|
2021-11-29 16:27:54 +01:00
|
|
|
|
let(:avis) { [create(:avis, claimant: instructeur, experts_procedure: experts_procedure, introduction_file: introduction_file)] }
|
2019-04-04 10:13:24 +02:00
|
|
|
|
let(:seen_at) { avis.first.created_at + 1.hour }
|
2017-12-07 11:15:51 +01:00
|
|
|
|
|
2019-04-04 10:13:24 +02:00
|
|
|
|
it { is_expected.to have_text(avis.first.introduction) }
|
|
|
|
|
it { is_expected.not_to have_css(".highlighted") }
|
2017-12-07 11:15:51 +01:00
|
|
|
|
|
2019-04-04 10:13:24 +02:00
|
|
|
|
context 'with a seen_at before avis created_at' do
|
2017-12-07 11:15:51 +01:00
|
|
|
|
let(:seen_at) { avis.first.created_at - 1.hour }
|
|
|
|
|
|
2021-11-29 16:27:54 +01:00
|
|
|
|
it { is_expected.to have_text("Fichier joint à la demande d’avis") }
|
2017-12-07 11:15:51 +01:00
|
|
|
|
it { is_expected.to have_css(".highlighted") }
|
|
|
|
|
end
|
2019-04-04 10:13:24 +02:00
|
|
|
|
|
|
|
|
|
context 'with an answer' do
|
2021-02-28 22:20:24 +01:00
|
|
|
|
let(:avis) { [create(:avis, :with_answer, claimant: instructeur, experts_procedure: experts_procedure)] }
|
2019-04-04 10:13:24 +02:00
|
|
|
|
|
|
|
|
|
it 'renders the answer formatted with newlines' do
|
2023-03-24 15:09:54 +01:00
|
|
|
|
expect(subject).to have_selector("p", text: avis.first.answer.split("\n").first)
|
|
|
|
|
expect(subject).to have_selector("ul.list-style-type-none ul", count: 1) # avis.answer has two list item
|
|
|
|
|
expect(subject).to have_selector("ul.list-style-type-none ul li", count: 2)
|
2019-04-04 10:13:24 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-29 16:27:54 +01:00
|
|
|
|
|
|
|
|
|
context 'with another instructeur' do
|
|
|
|
|
let(:avis) { [create(:avis, :with_answer, claimant: instructeur2, experts_procedure: experts_procedure, introduction_file: introduction_file)] }
|
|
|
|
|
|
|
|
|
|
it 'shows the files attached to the avis request' do
|
|
|
|
|
expect(subject).to have_text("Fichier joint à la demande d’avis")
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-12-07 11:15:51 +01:00
|
|
|
|
end
|