Merge pull request #2784 from betagouv/remove-remove-button

Remove the delete demarche feature for admins
This commit is contained in:
gregoirenovel 2018-10-09 16:55:12 +02:00 committed by GitHub
commit c703e1a312
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 137 deletions

View file

@ -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])

View file

@ -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

View file

@ -74,23 +74,3 @@
- else
.alert.alert-info
Cette démarche na pas encore de lien, et nest donc pas accessible par le public.
%br
- if @procedure.publiee_ou_archivee?
%h3 Supprimer la démarche
.alert.alert-danger
%p
Attention : la suppression dune 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 }

View file

@ -197,7 +197,6 @@ Rails.application.routes.draw do
end
member do
post :hide
delete :delete_logo
delete :delete_deliberation
delete :delete_notice

View file

@ -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) }

View file

@ -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