demarches-normaliennes/spec/views/users/dossiers/demande.html.haml_spec.rb

52 lines
1.9 KiB
Ruby
Raw Normal View History

2019-03-25 10:53:45 +01:00
describe 'users/dossiers/demande.html.haml', type: :view do
let(:procedure) { create(:procedure, :published, :with_type_de_champ, :with_type_de_champ_private) }
2018-08-14 15:06:44 +02:00
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure) }
before do
sign_in dossier.user
2018-08-14 15:06:44 +02:00
assign(:dossier, dossier)
end
subject! { render }
it 'renders the header' do
2018-10-08 18:44:19 +02:00
expect(rendered).to have_text("Dossier nº #{dossier.id}")
2018-08-14 15:06:44 +02:00
end
it 'renders the dossier infos' do
expect(rendered).to have_text('Déposé le')
2018-08-14 15:06:44 +02:00
expect(rendered).to have_text('Identité')
expect(rendered).to have_text('Demande')
2018-08-14 15:06:44 +02:00
end
context 'when the dossier is editable' do
it { is_expected.to have_link('Modifier le dossier', href: modifier_dossier_path(dossier)) }
end
context 'when the dossier is read-only' do
let(:dossier) { create(:dossier, :en_instruction, :with_entreprise, procedure: procedure) }
it { is_expected.not_to have_link('Modifier le dossier') }
end
context 'when the dossier has no depose_at date' do
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
it { expect(rendered).not_to have_text('Déposé le') }
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(rendered).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
2018-08-14 15:06:44 +02:00
end