commit
887c66a41e
5 changed files with 57 additions and 1 deletions
|
@ -136,6 +136,13 @@ module NewGestionnaire
|
||||||
redirect_to annotations_privees_gestionnaire_dossier_path(procedure, dossier)
|
redirect_to annotations_privees_gestionnaire_dossier_path(procedure, dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def purge_champ_piece_justificative
|
||||||
|
@champ = dossier.champs_private.find(params[:champ_id])
|
||||||
|
@champ.piece_justificative_file.purge
|
||||||
|
|
||||||
|
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||||
|
end
|
||||||
|
|
||||||
def print
|
def print
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
render layout: "print"
|
render layout: "print"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<%= render_flash(timeout: 5000, sticky: true) %>
|
||||||
|
<%= remove_element("#piece_justificative_#{@champ.id}") %>
|
|
@ -13,7 +13,10 @@
|
||||||
%div{ id: "piece_justificative_#{champ.id}" }
|
%div{ id: "piece_justificative_#{champ.id}" }
|
||||||
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
|
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
|
||||||
%br
|
%br
|
||||||
= link_to 'supprimer', purge_champ_piece_justificative_dossier_path(champ_id: champ.id), remote: true, method: :delete
|
- if champ.private?
|
||||||
|
= link_to 'supprimer', gestionnaire_champ_purge_champ_piece_justificative_path(procedure_id: champ.dossier.procedure_id, dossier_id: champ.dossier_id, champ_id: champ.id), remote: true, method: :delete
|
||||||
|
- else
|
||||||
|
= link_to 'supprimer', purge_champ_piece_justificative_dossier_path(champ_id: champ.id), remote: true, method: :delete
|
||||||
%br
|
%br
|
||||||
Modifier :
|
Modifier :
|
||||||
= form.file_field :piece_justificative_file,
|
= form.file_field :piece_justificative_file,
|
||||||
|
|
|
@ -327,6 +327,10 @@ Rails.application.routes.draw do
|
||||||
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
|
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
|
||||||
post 'avis' => 'dossiers#create_avis'
|
post 'avis' => 'dossiers#create_avis'
|
||||||
get 'print' => 'dossiers#print'
|
get 'print' => 'dossiers#print'
|
||||||
|
|
||||||
|
resources :champs, only: [] do
|
||||||
|
delete 'purge_champ_piece_justificative' => 'dossiers#purge_champ_piece_justificative'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -405,4 +405,44 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
it { expect(champ_datetime.value).to eq('21/12/2019 13:17') }
|
it { expect(champ_datetime.value).to eq('21/12/2019 13:17') }
|
||||||
it { expect(response).to redirect_to(annotations_privees_gestionnaire_dossier_path(dossier.procedure, dossier)) }
|
it { expect(response).to redirect_to(annotations_privees_gestionnaire_dossier_path(dossier.procedure, dossier)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#purge_champ_piece_justificative' do
|
||||||
|
before { sign_in(gestionnaire) }
|
||||||
|
|
||||||
|
subject { delete :purge_champ_piece_justificative, params: { procedure_id: champ.dossier.procedure.id, dossier_id: champ.dossier.id, champ_id: champ.id }, format: :js }
|
||||||
|
|
||||||
|
context 'when gestionnaire can process dossier' do
|
||||||
|
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
|
||||||
|
|
||||||
|
it { is_expected.to have_http_status(200) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
subject
|
||||||
|
expect(champ.reload.piece_justificative_file.attached?).to be(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'but champ is not linked to this dossier' do
|
||||||
|
let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier), private: true) }
|
||||||
|
|
||||||
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
subject
|
||||||
|
expect(champ.reload.piece_justificative_file.attached?).to be(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when gestionnaire cannot process dossier' do
|
||||||
|
let(:dossier){ create(:dossier, procedure: create(:procedure)) }
|
||||||
|
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
|
||||||
|
|
||||||
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
subject
|
||||||
|
expect(champ.reload.piece_justificative_file.attached?).to be(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue