2024-04-29 00:17:15 +02:00
# frozen_string_literal: true
2023-03-06 15:51:08 +01:00
describe 'users/dossiers/etablissement' , type : :view do
2023-03-15 10:39:14 +01:00
let ( :etablissement ) { create ( :etablissement , :with_exercices , siret : " 12345678900001 " ) }
2018-10-15 12:25:25 +02:00
let ( :dossier ) { create ( :dossier , etablissement : etablissement ) }
let ( :footer ) { view . content_for ( :footer ) }
before do
sign_in dossier . user
assign ( :dossier , dossier )
2020-08-05 18:40:47 +02:00
allow_any_instance_of ( APIEntrepriseToken ) . to receive ( :roles ) . and_return ( [ ] )
allow_any_instance_of ( APIEntrepriseToken ) . to receive ( :expired? ) . and_return ( false )
2018-10-15 12:25:25 +02:00
end
subject! { render }
it 'affiche les informations de l’ établissement' do
2023-03-15 11:10:32 +01:00
expect ( rendered ) . to have_text ( " 123 456 789 00001 " )
2023-03-15 10:39:14 +01:00
expect ( rendered ) . to have_text ( etablissement . entreprise_raison_sociale )
2018-10-15 12:25:25 +02:00
end
2020-03-11 14:53:26 +01:00
context 'etablissement avec infos non diffusables' do
2023-03-15 10:39:14 +01:00
let ( :etablissement ) { create ( :etablissement , :with_exercices , :non_diffusable , siret : " 12345678900001 " ) }
it " affiche uniquement le SIRET si infos non diffusables " do
2023-03-15 11:10:32 +01:00
expect ( rendered ) . to have_text ( " 123 456 789 00001 " )
2023-03-15 10:39:14 +01:00
expect ( rendered ) . not_to have_text ( etablissement . entreprise_raison_sociale )
2020-03-11 14:53:26 +01:00
expect ( rendered ) . not_to have_text ( etablissement . entreprise . forme_juridique )
end
end
2018-10-15 12:25:25 +02:00
it 'prépare le footer' do
expect ( footer ) . to have_selector ( 'footer' )
end
2022-09-16 00:32:17 +02:00
context 'etablissement as degraded mode' do
let ( :etablissement ) { Etablissement . create! ( siret : '41816609600051' ) }
it " affiche une notice avec un lien de vérification vers l'annuaire " do
2023-03-15 11:10:32 +01:00
expect ( rendered ) . to have_text ( " 418 166 096 00051 " )
2022-09-16 00:32:17 +02:00
expect ( rendered ) . to have_link ( " Vérifier dans l'annuaire des entreprises " , href : " https://annuaire-entreprises \ .data \ .gouv \ .fr/rechercher?terme= #{ etablissement . siret } " )
end
end
2018-10-15 12:25:25 +02:00
end