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)
|
2022-09-19 12:10:31 +02:00
|
|
|
|
# allow(view) doesn't work because method is called inside partial
|
|
|
|
|
ActionView::Base.any_instance.stub(: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
|
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
|