demarches-normaliennes/spec/views/instructeur/dossiers/show.html.haml_spec.rb
Colin Darie 9b929c86ea
Merge pull request #7760 from betagouv/dsfr-dossier-top-form
DSFR: convert dossier top form elements
2022-09-21 16:44:51 +02:00

54 lines
2 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

describe 'instructeurs/dossiers/show.html.haml', type: :view do
let(:current_instructeur) { create(:instructeur) }
let(:dossier) { create(:dossier, :en_construction) }
before do
sign_in(current_instructeur.user)
allow(view).to receive(:current_instructeur).and_return(current_instructeur)
assign(:dossier, dossier)
end
subject! { render }
it 'renders the header' do
expect(rendered).to have_text("Dossier nº #{dossier.id}")
end
it 'renders the dossier infos' do
expect(rendered).to have_text('Identité')
expect(rendered).to have_text('Demande')
end
context 'when the user is logged in with france connect' do
let(:france_connect_information) { build(:france_connect_information) }
let(:user) { build(:user, france_connect_information: france_connect_information) }
let(:procedure1) { create(:procedure, :with_type_de_champ, for_individual: true) }
let(:dossier) { create(:dossier, procedure: procedure1, user: user) }
before do
render
end
it 'fills the individual with the informations from France Connect' do
expect(view.content_for(:notice_info)).to have_text("Le dossier a été déposé par le compte de #{france_connect_information.given_name} #{france_connect_information.family_name}, authentifié par FranceConnect le #{france_connect_information.updated_at.strftime('%d/%m/%Y')}")
end
end
describe 'entreprise degraded mode' do
context 'etablissement complete' do
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, as_degraded_mode: false) }
it 'contains no warning' do
expect(rendered).not_to have_text("Les services de lINSEE sont indisponibles")
end
end
context 'etablissement in degraded mode' do
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, as_degraded_mode: true) }
it 'warns the instructeur' do
expect(rendered).to have_text("Les services de lINSEE sont indisponibles")
end
end
end
end