demarches-normaliennes/spec/views/experts/avis/instruction.html.haml_spec.rb
2024-08-22 09:26:48 +02:00

41 lines
1.5 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
describe 'experts/avis/instruction', type: :view do
let(:expert) { create(:expert) }
let(:claimant) { create(:instructeur) }
let(:procedure) { create(:procedure) }
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
let(:confidentiel) { false }
let(:avis) { create(:avis, confidentiel: confidentiel, claimant: claimant, experts_procedure: experts_procedure) }
before do
assign(:avis, avis)
assign(:new_avis, Avis.new)
assign(:dossier, avis.dossier)
allow(view).to receive(:current_expert).and_return(avis.expert)
end
subject { render }
context 'with a confidential avis' do
let(:confidentiel) { true }
it { is_expected.to have_text("Cet avis est confidentiel et nest pas affiché aux autres experts consultés") }
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
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
end