[fix #1897] Procedure: can delete a deliberation

This commit is contained in:
simon lehericey 2018-05-31 11:15:44 +02:00
parent 0e690c90cc
commit 18ad227df5
4 changed files with 24 additions and 0 deletions

View file

@ -217,6 +217,15 @@ class Admin::ProceduresController < AdminController
render json: json_path_list render json: json_path_list
end end
def delete_deliberation
procedure = Procedure.find(params[:id])
procedure.deliberation.purge_later
flash.notice = 'la délibération a bien été supprimée'
redirect_to edit_admin_procedure_path(procedure)
end
private private
def cloned_from_library? def cloned_from_library?

View file

@ -35,6 +35,8 @@
- else - else
%a{ href: url_for(deliberation), target: '_blank' } %a{ href: url_for(deliberation), target: '_blank' }
= deliberation.filename.to_s = deliberation.filename.to_s
= link_to 'supprimer', delete_deliberation_admin_procedure_path(@procedure),
method: :delete
%br %br
Modifier : Modifier :
= f.file_field :deliberation, = f.file_field :deliberation,

View file

@ -147,6 +147,7 @@ Rails.application.routes.draw do
member do member do
post :hide post :hide
delete :delete_deliberation
end end
resources :types_de_champ, only: [:destroy] resources :types_de_champ, only: [:destroy]

View file

@ -637,4 +637,16 @@ describe Admin::ProceduresController, type: :controller do
end end
end end
end end
describe "DELETE #delete_deliberation" do
let(:procedure) { create(:procedure, :with_deliberation) }
before do
delete :delete_deliberation, params: { id: procedure.id }
procedure.reload
end
it { expect(procedure.deliberation.attached?).to eq(false) }
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) }
end
end end