From 6914d78236cf02263b3457c3c7fe9672c4d39358 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 26 Nov 2024 14:28:52 +0100 Subject: [PATCH] refactor(user/dossier): explicitly pass dossier_for_editing in to views --- app/views/administrateurs/procedures/apercu.html.haml | 2 +- app/views/instructeurs/procedures/apercu.html.haml | 2 +- app/views/shared/dossiers/_edit.html.haml | 4 +--- app/views/users/dossiers/brouillon.html.haml | 2 +- app/views/users/dossiers/modifier.html.haml | 2 +- spec/views/shared/dossiers/_edit.html.haml_spec.rb | 4 +++- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/administrateurs/procedures/apercu.html.haml b/app/views/administrateurs/procedures/apercu.html.haml index 5941fdbb4..c847b25b8 100644 --- a/app/views/administrateurs/procedures/apercu.html.haml +++ b/app/views/administrateurs/procedures/apercu.html.haml @@ -13,6 +13,6 @@ active: @tab == 'annotations-privees') - if @tab == 'dossier' - = render partial: "shared/dossiers/edit", locals: { dossier: @dossier } + = render partial: "shared/dossiers/edit", locals: { dossier: @dossier, dossier_for_editing: @dossier } - else = render partial: "shared/dossiers/edit_annotations", locals: { dossier: @dossier, seen_at: nil } diff --git a/app/views/instructeurs/procedures/apercu.html.haml b/app/views/instructeurs/procedures/apercu.html.haml index 6d6d315b4..2c417f139 100644 --- a/app/views/instructeurs/procedures/apercu.html.haml +++ b/app/views/instructeurs/procedures/apercu.html.haml @@ -12,4 +12,4 @@ .fr-container %h2.fr-h4= t('.title') -= render partial: "shared/dossiers/edit", locals: { dossier: @dossier } += render partial: "shared/dossiers/edit", locals: { dossier: @dossier, dossier_for_editing: @dossier } diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index 3bdc70ec0..1adde72ac 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -1,5 +1,3 @@ -- dossier_for_editing = dossier.en_construction? ? dossier.owner_editing_fork : dossier - - if dossier.france_connected_with_one_identity? && current_user.instructeur? && !current_user.owns_or_invite?(dossier) - content_for(:notice_info) do = render partial: "shared/dossiers/france_connect_informations_notice", locals: { user_information: dossier.user.france_connect_informations.first } @@ -10,7 +8,7 @@ = render NestedForms::FormOwnerComponent.new = form_for dossier_for_editing, url: brouillon_dossier_url(dossier), method: :patch, html: { id: 'dossier-edit-form', class: 'form', multipart: true, novalidate: 'novalidate' } do |f| - = render Dossiers::ErrorsFullMessagesComponent.new(dossier: dossier) + = render Dossiers::ErrorsFullMessagesComponent.new(dossier: dossier_for_editing) %header.mb-6 .fr-highlight %p.fr-text--sm diff --git a/app/views/users/dossiers/brouillon.html.haml b/app/views/users/dossiers/brouillon.html.haml index 0acdb89e5..428347daf 100644 --- a/app/views/users/dossiers/brouillon.html.haml +++ b/app/views/users/dossiers/brouillon.html.haml @@ -9,4 +9,4 @@ .fr-container = render partial: "shared/dossiers/header", locals: { dossier: @dossier } - = render partial: "shared/dossiers/edit", locals: { dossier: @dossier } + = render partial: "shared/dossiers/edit", locals: { dossier: @dossier, dossier_for_editing: @dossier } diff --git a/app/views/users/dossiers/modifier.html.haml b/app/views/users/dossiers/modifier.html.haml index 7217909e0..6a2b98675 100644 --- a/app/views/users/dossiers/modifier.html.haml +++ b/app/views/users/dossiers/modifier.html.haml @@ -7,4 +7,4 @@ = render partial: 'users/dossiers/show/header', locals: { dossier: @dossier } .container - = render partial: "shared/dossiers/edit", locals: { dossier: @dossier } + = render partial: "shared/dossiers/edit", locals: { dossier: @dossier, dossier_for_editing: @dossier_for_editing } diff --git a/spec/views/shared/dossiers/_edit.html.haml_spec.rb b/spec/views/shared/dossiers/_edit.html.haml_spec.rb index efccf5c7d..d2222c027 100644 --- a/spec/views/shared/dossiers/_edit.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_edit.html.haml_spec.rb @@ -6,10 +6,11 @@ describe 'shared/dossiers/edit', type: :view do allow(view).to receive(:administrateur_signed_in?).and_return(false) end - subject { render 'shared/dossiers/edit', dossier: dossier, apercu: false } + subject { render 'shared/dossiers/edit', dossier:, dossier_for_editing:, apercu: false } let(:procedure) { create(:procedure, types_de_champ_public:) } let(:dossier) { create(:dossier, :with_populated_champs, procedure:) } + let(:dossier_for_editing) { dossier } context 'when there are some champs' do let(:type_de_champ_header_section) { procedure.draft_types_de_champ_public.find(&:header_section?) } @@ -116,6 +117,7 @@ describe 'shared/dossiers/edit', type: :view do context 'when dossier is en construction' do let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure:) } + let(:dossier_for_editing) { dossier.owner_editing_fork } it 'can delete a piece justificative' do expect(subject).to have_selector("[title='Supprimer le fichier #{champ.piece_justificative_file.attachments[0].filename}']")