feat(procedure): warn administrator that notice links are not shareable

Closes #7681
This commit is contained in:
Colin Darie 2022-09-19 12:10:31 +02:00
parent 6a943ad13f
commit da22c29688
2 changed files with 38 additions and 15 deletions

View file

@ -26,6 +26,11 @@
class: "fr-btn fr-btn--secondary mt-2",
title: t("views.shared.dossiers.edit.notice_title"), **external_link_attributes
- if administrateur_signed_in?
%em.ml-1.fr-text-mention--grey.visible-on-previous-hover
%span.fr-icon-feedback-line{ "aria-hidden": "true" }
= t('shared.ephemeral_link')
- if dossier.show_groupe_instructeur_selector?
%span{ data: { controller: 'autosave' } }
= f.label :groupe_instructeur_id do

View file

@ -2,32 +2,50 @@ describe 'users/dossiers/brouillon.html.haml', type: :view do
let(:procedure) { create(:procedure, :with_type_de_champ, :with_notice, :with_service) }
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
let(:footer) { view.content_for(:footer) }
let(:profile) { :user }
before do
sign_in dossier.user
assign(:dossier, dossier)
# allow(view) doesn't work because method is called inside partial
ActionView::Base.any_instance.stub(:administrateur_signed_in?).and_return(profile == :administrateur)
end
subject! { render }
it 'affiche le libellé de la démarche' do
expect(rendered).to have_text(dossier.procedure.libelle)
context "as an user" do
it 'affiche le libellé de la démarche' do
expect(rendered).to have_text(dossier.procedure.libelle)
end
it 'affiche un lien vers la notice' do
expect(response).to have_css("a[href*='/rails/active_storage/blobs/']", text: "Guide de la démarche")
expect(rendered).not_to have_text("Ce lien est éphémère")
end
it 'affiche les boutons de validation' do
expect(rendered).to have_selector('.send-dossier-actions-bar')
end
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) }
it { is_expected.not_to have_link("Guide de la démarche") }
end
end
it 'affiche un lien vers la notice' do
expect(response).to have_css("a[href*='/rails/active_storage/blobs/']", text: "Guide de la démarche")
end
context "as an administrateur" do
let(:profile) { :administrateur }
it 'affiche les boutons de validation' do
expect(rendered).to have_selector('.send-dossier-actions-bar')
end
before do
create(:administrateur, user: dossier.user)
end
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) }
it { is_expected.not_to have_link("Guide de la démarche") }
it 'affiche un avertissement à propos de la notice' do
expect(rendered).to have_text("Ce lien est éphémère")
end
end
end