Remove the delete demarche feature for admins
This commit is contained in:
parent
94061ec0ce
commit
98d348aab1
6 changed files with 0 additions and 137 deletions
|
@ -44,14 +44,6 @@ class Admin::ProceduresController < AdminController
|
|||
@mine = @procedure.path_is_mine?(@path)
|
||||
end
|
||||
|
||||
def hide
|
||||
procedure = current_administrateur.procedures.find(params[:id])
|
||||
procedure.hide!
|
||||
|
||||
flash.notice = "Démarche supprimée, en cas d'erreur #{helpers.contact_link('contactez nous', tags: 'démarche supprimée')}"
|
||||
redirect_to admin_procedures_draft_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
procedure = current_administrateur.procedures.find(params[:id])
|
||||
|
||||
|
|
|
@ -19,29 +19,4 @@ module ProcedureHelper
|
|||
action = procedure.archivee? ? :reopen : :publish
|
||||
t(action, scope: [:modal, :publish, key])
|
||||
end
|
||||
|
||||
def dossiers_deletion_warning(procedure)
|
||||
dossiers_count = procedure.dossiers.state_not_brouillon.count
|
||||
brouillons_count = procedure.dossiers.state_brouillon.count
|
||||
formatted_dossiers_count = nil
|
||||
formatted_brouillons_count = nil
|
||||
|
||||
if dossiers_count > 0
|
||||
formatted_dossiers_count = pluralize(dossiers_count, "dossier", "dossiers")
|
||||
end
|
||||
|
||||
if brouillons_count > 0
|
||||
formatted_brouillons_count = pluralize(brouillons_count, "brouillon", "brouillons")
|
||||
end
|
||||
|
||||
formatted_combination = [formatted_dossiers_count, formatted_brouillons_count]
|
||||
.compact
|
||||
.join(" et ")
|
||||
|
||||
[
|
||||
formatted_combination,
|
||||
dossiers_count + brouillons_count == 1 ? "est rattaché" : "sont rattachés",
|
||||
"à cette démarche, la suppression de cette démarche entrainera également leur suppression."
|
||||
].join(" ")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,23 +74,3 @@
|
|||
- else
|
||||
.alert.alert-info
|
||||
Cette démarche n’a pas encore de lien, et n’est donc pas accessible par le public.
|
||||
|
||||
%br
|
||||
|
||||
- if @procedure.publiee_ou_archivee?
|
||||
%h3 Supprimer la démarche
|
||||
.alert.alert-danger
|
||||
%p
|
||||
Attention : la suppression d’une démarche est définitive.
|
||||
|
||||
- dossiers_count = @procedure.dossiers.count
|
||||
- if dossiers_count > 0
|
||||
%p
|
||||
= dossiers_deletion_warning(@procedure)
|
||||
|
||||
%p.text-right
|
||||
= link_to "J'ai compris, je supprime la démarche",
|
||||
hide_admin_procedure_path(@procedure),
|
||||
method: :post,
|
||||
class: "btn btn-danger",
|
||||
data: { confirm: "Voulez-vous supprimer la démarche ?", disable: true }
|
||||
|
|
|
@ -197,7 +197,6 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
member do
|
||||
post :hide
|
||||
delete :delete_logo
|
||||
delete :delete_deliberation
|
||||
delete :delete_notice
|
||||
|
|
|
@ -680,38 +680,6 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST #hide" do
|
||||
subject { post :hide, params: { id: procedure.id } }
|
||||
|
||||
context "when procedure is not owned by administrateur" do
|
||||
let(:procedure) { create :procedure, administrateur: create(:administrateur) }
|
||||
|
||||
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
|
||||
context "when procedure is owned by administrateur" do
|
||||
let(:procedure) { create :procedure, :published, administrateur: admin }
|
||||
|
||||
before do
|
||||
subject
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.hidden_at).not_to be_nil }
|
||||
it { expect(procedure.procedure_path).to be_nil }
|
||||
end
|
||||
|
||||
context "when procedure has no path" do
|
||||
let(:procedure) { create :procedure, administrateur: admin }
|
||||
|
||||
it { expect{ subject }.not_to raise_error }
|
||||
it do
|
||||
subject
|
||||
expect(procedure.reload.hidden_at).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #delete_deliberation" do
|
||||
context "with a demarche the admin owns" do
|
||||
let(:procedure) { create(:procedure, :with_deliberation, administrateur: admin) }
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
RSpec.describe ProcedureHelper, type: :helper do
|
||||
let(:procedure) { create(:procedure) }
|
||||
|
||||
describe '#dossiers_deletion_warning' do
|
||||
subject { dossiers_deletion_warning(procedure) }
|
||||
|
||||
context 'with 1 submitted dossier' do
|
||||
before do
|
||||
dossier_1 = create(:dossier, :en_construction, procedure: procedure)
|
||||
end
|
||||
|
||||
it { is_expected.to eq('1 dossier est rattaché à cette démarche, la suppression de cette démarche entrainera également leur suppression.') }
|
||||
end
|
||||
|
||||
context 'with 2 submitted dossiers' do
|
||||
before do
|
||||
dossier_1 = create(:dossier, :en_construction, procedure: procedure)
|
||||
dossier_2 = create(:dossier, :en_instruction, procedure: procedure)
|
||||
end
|
||||
|
||||
it { is_expected.to eq('2 dossiers sont rattachés à cette démarche, la suppression de cette démarche entrainera également leur suppression.') }
|
||||
end
|
||||
|
||||
context 'with 1 brouillon dossier' do
|
||||
before do
|
||||
dossier_1 = create(:dossier, procedure: procedure)
|
||||
end
|
||||
|
||||
it { is_expected.to eq('1 brouillon est rattaché à cette démarche, la suppression de cette démarche entrainera également leur suppression.') }
|
||||
end
|
||||
|
||||
context 'with 2 brouillons dossiers' do
|
||||
before do
|
||||
dossier_1 = create(:dossier, procedure: procedure)
|
||||
dossier_2 = create(:dossier, procedure: procedure)
|
||||
end
|
||||
|
||||
it { is_expected.to eq('2 brouillons sont rattachés à cette démarche, la suppression de cette démarche entrainera également leur suppression.') }
|
||||
end
|
||||
|
||||
context 'with 2 submitted dossiers and 1 brouillon dossier' do
|
||||
before do
|
||||
dossier_1 = create(:dossier, :en_instruction, procedure: procedure)
|
||||
dossier_2 = create(:dossier, :en_instruction, procedure: procedure)
|
||||
dossier_3 = create(:dossier, procedure: procedure)
|
||||
end
|
||||
|
||||
it { is_expected.to eq('2 dossiers et 1 brouillon sont rattachés à cette démarche, la suppression de cette démarche entrainera également leur suppression.') }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue