refactor(user/dossier): explicitly pass dossier_for_editing in to views

This commit is contained in:
Paul Chavard 2024-11-26 14:28:52 +01:00
parent fb6adabfc5
commit 6914d78236
No known key found for this signature in database
6 changed files with 8 additions and 8 deletions

View file

@ -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 }

View file

@ -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 }

View file

@ -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

View file

@ -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 }

View file

@ -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 }

View file

@ -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}']")