feat(champ_pj): warn administrators about ephemeral template links
Closes #7681
This commit is contained in:
parent
0f6a611b6f
commit
6a943ad13f
6 changed files with 42 additions and 2 deletions
|
@ -74,6 +74,14 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
.visible-on-previous-hover {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
:hover + .visible-on-previous-hover {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
// sizing
|
||||
.width-100 {
|
||||
width: 100%;
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
Veuillez télécharger, remplir et joindre
|
||||
= link_to('le modèle suivant', url_for(template), target: '_blank', rel: 'noopener')
|
||||
|
||||
- if helpers.administrateur_signed_in?
|
||||
%em.fr-text-mention--grey.fr-text--xs.visible-on-previous-hover
|
||||
= t('shared.ephemeral_link')
|
||||
|
||||
- if persisted?
|
||||
.attachment-actions{ id: dom_id(attachment, :actions) }
|
||||
.attachment-action
|
||||
|
|
|
@ -500,6 +500,7 @@ en:
|
|||
connection_done: "The accounts for FranceConnect and %{application_name} are now merged."
|
||||
merger_token_expired: "Le delay to merge your FranceConnect and %{application_name} accounts is expired. Please retry."
|
||||
shared:
|
||||
ephemeral_link: This link is ephemeral and should not be shared.
|
||||
procedures:
|
||||
stats:
|
||||
usual_processing_time: "Usual processing time"
|
||||
|
|
|
@ -551,6 +551,7 @@ fr:
|
|||
connection_done: "Les comptes FranceConnect et %{application_name} sont à présent fusionnés"
|
||||
merger_token_expired: "Le délai pour fusionner les comptes FranceConnect et %{application_name} est expirée. Veuillez recommencer la procédure pour vous fusionner les comptes."
|
||||
shared:
|
||||
ephemeral_link: Ce lien est éphémère et ne devrait pas être partagé.
|
||||
procedures:
|
||||
stats:
|
||||
usual_processing_time: "Temps de traitement usuel"
|
||||
|
|
|
@ -2,10 +2,11 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
|||
let(:champ) { build(:champ_piece_justificative, dossier: create(:dossier)) }
|
||||
let(:attached_file) { champ.piece_justificative_file }
|
||||
let(:user_can_destroy) { false }
|
||||
let(:template) { nil }
|
||||
|
||||
subject do
|
||||
form_for(champ.dossier) do |form|
|
||||
view.render Attachment::EditComponent.new(form: form, attached_file: attached_file, user_can_destroy: true, direct_upload: true)
|
||||
view.render Attachment::EditComponent.new(form: form, attached_file: attached_file, user_can_destroy: true, direct_upload: true, template:)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,4 +65,26 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
|||
is_expected.not_to have_link('Supprimer')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when champ has a template' do
|
||||
let(:profil) { :user }
|
||||
let(:template) { champ.type_de_champ.piece_justificative_template }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(ActionView::Base).to receive(:administrateur_signed_in?).and_return(profil == :administrateur)
|
||||
end
|
||||
|
||||
it 'renders a link to template' do
|
||||
expect(subject).to have_link('le modèle suivant')
|
||||
expect(subject).not_to have_text("éphémère")
|
||||
end
|
||||
|
||||
context 'as an administrator' do
|
||||
let(:profil) { :administrateur }
|
||||
it 'warn about ephemeral template url' do
|
||||
expect(subject).to have_link('le modèle suivant')
|
||||
expect(subject).to have_text("éphémère")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
describe 'shared/dossiers/edit.html.haml', type: :view do
|
||||
before do
|
||||
allow(controller).to receive(:current_user).and_return(dossier.user)
|
||||
allow(view).to receive(:administrateur_signed_in?).and_return(false)
|
||||
end
|
||||
|
||||
subject { render 'shared/dossiers/edit.html.haml', dossier: dossier, apercu: false }
|
||||
|
@ -118,7 +119,9 @@ describe 'shared/dossiers/edit.html.haml', type: :view do
|
|||
end
|
||||
|
||||
context 'when dossier is brouillon' do
|
||||
before { dossier.champs << champ }
|
||||
before do
|
||||
dossier.champs << champ
|
||||
end
|
||||
|
||||
it 'can delete a piece justificative' do
|
||||
expect(subject).to have_text('Supprimer')
|
||||
|
|
Loading…
Reference in a new issue