dossiers: refresh the whole header actions bar on status change

This ensure the other state-dependant buttons get updated to–like the
"Follow" or "Archive" button.

Fix #4186
This commit is contained in:
Pierre de La Morinerie 2019-08-12 14:46:38 +00:00 committed by Nicolas Bouilleaud
parent 3a37c1eeae
commit 79784089a4
3 changed files with 11 additions and 10 deletions

View file

@ -1,5 +1,5 @@
<%= render_flash %>
<%= render_to_element('.state-button', partial: "state_button", locals: { dossier: dossier }) %>
<%= render_to_element('.header-actions', partial: 'header_actions', locals: { dossier: dossier }) %>
<% attachment = dossier.justificatif_motivation.attachment %>
<% if attachment && attachment.virus_scanner.pending? %>

View file

@ -117,7 +117,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
it { expect(instructeur.follow?(dossier)).to be true }
it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.state-button') }
it { expect(response.body).to include('.header-actions') }
context 'when the dossier has already been put en_instruction' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
@ -141,7 +141,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.state-button') }
it { expect(response.body).to include('.header-actions') }
context 'when the dossier has already been put en_construction' do
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
@ -166,7 +166,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.state-button') }
it { expect(response.body).to include('.header-actions') }
context 'when the dossier has already been put en_instruction' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
@ -239,7 +239,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached
end
it { expect(subject.body).to include('.state-button') }
it { expect(subject.body).to include('.header-actions') }
end
end
@ -267,7 +267,7 @@ describe Instructeurs::DossiersController, type: :controller do
subject
end
it { expect(subject.body).to include('.state-button') }
it { expect(subject.body).to include('.header-actions') }
end
context 'with attachment' do
@ -281,7 +281,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached
end
it { expect(subject.body).to include('.state-button') }
it { expect(subject.body).to include('.header-actions') }
end
end
@ -322,14 +322,14 @@ describe Instructeurs::DossiersController, type: :controller do
end
it 'The instructeur is sent back to the dossier page' do
expect(subject.body).to include('.state-button')
expect(subject.body).to include('.header-actions')
end
context 'and the dossier has already an attestation' do
it 'should not crash' do
dossier.attestation = Attestation.new
dossier.save
expect(subject.body).to include('.state-button')
expect(subject.body).to include('.header-actions')
end
end
end
@ -372,7 +372,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached
end
it { expect(subject.body).to include('.state-button') }
it { expect(subject.body).to include('.header-actions') }
end
end

View file

@ -67,6 +67,7 @@ feature 'The instructeur part' do
end
expect(page).to have_text('Dossier traité avec succès.')
expect(page).to have_link('Archiver le dossier')
dossier.reload
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))