[fix #1897] Procedure: can delete a deliberation
This commit is contained in:
parent
0e690c90cc
commit
18ad227df5
4 changed files with 24 additions and 0 deletions
|
@ -217,6 +217,15 @@ class Admin::ProceduresController < AdminController
|
|||
render json: json_path_list
|
||||
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
|
||||
|
||||
def cloned_from_library?
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
- else
|
||||
%a{ href: url_for(deliberation), target: '_blank' }
|
||||
= deliberation.filename.to_s
|
||||
= link_to 'supprimer', delete_deliberation_admin_procedure_path(@procedure),
|
||||
method: :delete
|
||||
%br
|
||||
Modifier :
|
||||
= f.file_field :deliberation,
|
||||
|
|
|
@ -147,6 +147,7 @@ Rails.application.routes.draw do
|
|||
|
||||
member do
|
||||
post :hide
|
||||
delete :delete_deliberation
|
||||
end
|
||||
|
||||
resources :types_de_champ, only: [:destroy]
|
||||
|
|
|
@ -637,4 +637,16 @@ describe Admin::ProceduresController, type: :controller do
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue