2023-03-06 15:51:08 +01:00
|
|
|
|
describe 'experts/avis/instruction', type: :view do
|
2021-02-28 22:20:24 +01:00
|
|
|
|
let(:expert) { create(:expert) }
|
|
|
|
|
let(:claimant) { create(:instructeur) }
|
|
|
|
|
let(:procedure) { create(:procedure) }
|
2022-05-10 12:51:27 +02:00
|
|
|
|
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
2023-03-28 15:38:13 +02:00
|
|
|
|
let(:confidentiel) { false }
|
2022-05-10 12:51:27 +02:00
|
|
|
|
let(:avis) { create(:avis, confidentiel: confidentiel, claimant: claimant, experts_procedure: experts_procedure) }
|
2018-11-22 18:28:08 +01:00
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
assign(:avis, avis)
|
2019-10-21 11:45:03 +02:00
|
|
|
|
assign(:new_avis, Avis.new)
|
|
|
|
|
assign(:dossier, avis.dossier)
|
2021-02-28 22:20:24 +01:00
|
|
|
|
allow(view).to receive(:current_expert).and_return(avis.expert)
|
2018-11-22 18:28:08 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
subject { render }
|
|
|
|
|
|
|
|
|
|
context 'with a confidential avis' do
|
|
|
|
|
let(:confidentiel) { true }
|
2022-05-10 12:51:27 +02:00
|
|
|
|
it { is_expected.to have_text("Cet avis est confidentiel et n’est pas affiché aux autres experts consultés") }
|
2018-11-22 18:28:08 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with a not confidential avis' do
|
|
|
|
|
let(:confidentiel) { false }
|
|
|
|
|
it { is_expected.to have_text("Cet avis est partagé avec les autres experts") }
|
|
|
|
|
end
|
2023-03-28 15:38:13 +02:00
|
|
|
|
|
|
|
|
|
context 'when the avis has a question' do
|
|
|
|
|
let(:avis) { create(:avis, question_label: "is it useful?", claimant: claimant, experts_procedure: experts_procedure) }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to have_text(avis.question_label) }
|
|
|
|
|
it { is_expected.to have_unchecked_field("oui") }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when the avis has no question' do
|
|
|
|
|
let(:avis) { create(:avis, question_label: "", claimant: claimant, experts_procedure: experts_procedure) }
|
|
|
|
|
it { is_expected.not_to have_unchecked_field("oui") }
|
|
|
|
|
end
|
2018-11-22 18:28:08 +01:00
|
|
|
|
end
|