2024-04-29 00:17:15 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
|
describe 'users/dossiers/brouillon', type: :view do
|
2020-01-07 17:50:49 +01:00
|
|
|
|
let(:procedure) { create(:procedure, :with_type_de_champ, :with_notice, :with_service) }
|
|
|
|
|
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
|
2018-06-19 16:23:43 +02:00
|
|
|
|
let(:footer) { view.content_for(:footer) }
|
2022-09-19 12:10:31 +02:00
|
|
|
|
let(:profile) { :user }
|
2018-06-19 16:23:43 +02:00
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
sign_in dossier.user
|
|
|
|
|
assign(:dossier, dossier)
|
2023-11-09 17:43:20 +01:00
|
|
|
|
allow_any_instance_of(ActionView::Base).to receive(:administrateur_signed_in?).and_return(profile == :administrateur)
|
2018-06-19 16:23:43 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-07-09 15:55:58 +02:00
|
|
|
|
subject! { render }
|
2018-06-19 16:23:43 +02:00
|
|
|
|
|
2022-09-19 12:10:31 +02:00
|
|
|
|
context "as an user" do
|
|
|
|
|
it 'affiche le libellé de la démarche' do
|
|
|
|
|
expect(rendered).to have_text(dossier.procedure.libelle)
|
|
|
|
|
end
|
2018-06-19 16:23:43 +02:00
|
|
|
|
|
2022-09-19 12:10:31 +02:00
|
|
|
|
it 'affiche un lien vers la notice' do
|
2022-10-04 13:17:25 +02:00
|
|
|
|
expect(response).to have_css("a[href*='/rails/active_storage/blobs/']", text: "Télécharger le guide de la démarche")
|
2022-09-19 12:10:31 +02:00
|
|
|
|
expect(rendered).not_to have_text("Ce lien est éphémère")
|
2022-10-04 13:17:25 +02:00
|
|
|
|
expect(rendered).to have_text("TXT – 11 octets")
|
2022-09-19 12:10:31 +02:00
|
|
|
|
end
|
2018-07-11 17:11:44 +02:00
|
|
|
|
|
2022-09-19 12:10:31 +02:00
|
|
|
|
it 'affiche les boutons de validation' do
|
|
|
|
|
expect(rendered).to have_selector('.send-dossier-actions-bar')
|
|
|
|
|
end
|
2018-06-19 16:23:43 +02:00
|
|
|
|
|
2022-09-19 12:10:31 +02:00
|
|
|
|
it 'prépare le footer' do
|
|
|
|
|
expect(footer).to have_selector('footer')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'quand la démarche ne comporte pas de notice' do
|
|
|
|
|
let(:procedure) { create(:procedure) }
|
2022-10-04 13:17:25 +02:00
|
|
|
|
it { is_expected.not_to have_link("Télécharger le guide de la démarche") }
|
2022-09-19 12:10:31 +02:00
|
|
|
|
end
|
2023-11-27 15:52:55 +01:00
|
|
|
|
|
2023-12-11 17:06:12 +01:00
|
|
|
|
context 'when a dossier is for_tiers and the dossier en construction with email notification' do
|
2023-11-27 15:52:55 +01:00
|
|
|
|
let(:dossier) { create(:dossier, :for_tiers_with_notification) }
|
|
|
|
|
|
2023-12-11 17:06:12 +01:00
|
|
|
|
it 'displays the informations of the beneficiaire' do
|
|
|
|
|
expect(rendered).to have_text("Identité du demandeur")
|
|
|
|
|
expect(rendered).not_to have_text("Votre identité")
|
2023-11-27 15:52:55 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
2018-06-19 16:23:43 +02:00
|
|
|
|
end
|
2018-07-11 17:11:44 +02:00
|
|
|
|
|
2022-09-19 12:10:31 +02:00
|
|
|
|
context "as an administrateur" do
|
|
|
|
|
let(:profile) { :administrateur }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
create(:administrateur, user: dossier.user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affiche un avertissement à propos de la notice' do
|
|
|
|
|
expect(rendered).to have_text("Ce lien est éphémère")
|
|
|
|
|
end
|
2018-07-11 17:11:44 +02:00
|
|
|
|
end
|
2018-06-19 16:23:43 +02:00
|
|
|
|
end
|