fix(dossier): submit en_construction render views in error with dossier origin

This commit is contained in:
Colin Darie 2023-05-09 18:04:34 +02:00
parent 218c7d08c2
commit b626714610
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 9 additions and 1 deletions

View file

@ -229,7 +229,11 @@ module Users
flash.now.alert = errors
respond_to do |format|
format.html { render :modifier }
format.html do
@dossier = @dossier.editing_fork_origin
render :modifier
end
format.turbo_stream do
@to_show, @to_hide, @to_update = champs_to_turbo_update(champs_public_params.fetch(:champs_public_all_attributes), dossier.champs_public_all)
render :update, layout: false

View file

@ -475,16 +475,20 @@ describe Users::DossiersController, type: :controller do
end
context 'when the update fails' do
render_views
before do
expect_any_instance_of(Dossier).to receive(:valid?).and_return(false)
expect_any_instance_of(Dossier).to receive(:errors).and_return(
[double(class: ActiveModel::Error, full_message: 'nop', base: first_champ)]
)
subject
end
it { expect(response).to render_template(:modifier) }
it { expect(flash.alert).to eq(["Le champ « #{first_champ.libelle} » nop, #{anchor_to_first_champ}"]) }
it { expect(response.body).to include("Dossier nº #{dossier.id}") }
end
context 'when a mandatory champ is missing' do