2023-03-06 15:51:08 +01:00
describe 'users/dossiers/demande' , type : :view do
2019-07-25 15:57:00 +02:00
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
2018-09-20 14:05:18 +02:00
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
2019-02-19 11:41:20 +01:00
expect ( rendered ) . to have_text ( 'Déposé le' )
2018-08-14 15:06:44 +02:00
expect ( rendered ) . to have_text ( 'Identité' )
2018-08-29 16:57:01 +02:00
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
2019-02-19 11:41:20 +01:00
2021-12-06 15:49:17 +01:00
context 'when the dossier has no depose_at date' do
2019-02-19 11:41:20 +01:00
let ( :dossier ) { create ( :dossier , :with_entreprise , procedure : procedure ) }
it { expect ( rendered ) . not_to have_text ( 'Déposé le' ) }
end
2020-11-02 11:37:21 +01:00
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
2024-03-01 09:50:39 +01:00
it 'does not fill the individual with the informations from France Connect' do
expect ( view . content_for ( :notice_info ) ) . not_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' ) } " )
2020-11-02 11:37:21 +01:00
end
end
2023-11-27 15:52:55 +01:00
context 'when a dossier is for_tiers and the dossier is en_construction with email notification' do
let ( :dossier ) { create ( :dossier , :en_construction , :for_tiers_with_notification ) }
it 'displays the informations of the mandataire' do
2023-12-11 17:06:12 +01:00
expect ( rendered ) . to have_text ( 'Identité du mandataire' )
expect ( rendered ) . to have_text ( dossier . mandataire_first_name . to_s )
expect ( rendered ) . to have_text ( dossier . mandataire_last_name . to_s )
2023-11-27 15:52:55 +01:00
expect ( rendered ) . to have_text ( dossier . individual . email . to_s )
end
end
2018-08-14 15:06:44 +02:00
end