Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the delete demarche feature for admins #2784

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/controllers/admin/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ def edit
@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])

Expand Down
25 changes: 0 additions & 25 deletions app/helpers/procedure_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,4 @@ def procedure_modal_text(procedure, key)
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
20 changes: 0 additions & 20 deletions app/views/admin/procedures/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@
end

member do
post :hide
delete :delete_logo
delete :delete_deliberation
delete :delete_notice
Expand Down
32 changes: 0 additions & 32 deletions spec/controllers/admin/procedures_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -680,38 +680,6 @@ def update_procedure
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) }
Expand Down
51 changes: 0 additions & 51 deletions spec/helpers/procedure_helper_spec.rb

This file was deleted.