controllers: remove dead code on Admin::ProceduresController

This code has been migrated to NewAdministrateur::ProceduresController.
This commit is contained in:
Pierre de La Morinerie 2021-09-02 14:51:26 -05:00
parent 3fc934c8fb
commit 7729385d89
3 changed files with 1 additions and 151 deletions

View file

@ -1,45 +1,4 @@
class Admin::ProceduresController < AdminController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :retrieve_procedure, only: [:show, :delete_logo, :delete_deliberation, :delete_notice, :publish]
def index
if current_administrateur.procedures.count != 0
@procedures = smart_listing_create :procedures,
current_administrateur.procedures.publiees.order(published_at: :desc),
partial: "admin/procedures/list",
array: true
active_class
else
redirect_to new_from_existing_admin_procedures_path
end
end
def show
if @procedure.brouillon?
@procedure_lien = commencer_test_url(path: @procedure.path)
else
@procedure_lien = commencer_url(path: @procedure.path)
end
@procedure.path = @procedure.suggested_path(current_administrateur)
@current_administrateur = current_administrateur
end
def destroy
procedure = current_administrateur.procedures.find(params[:id])
if procedure.can_be_deleted_by_administrateur?
procedure.discard_and_keep_track!(current_administrateur)
flash.notice = 'Démarche supprimée'
redirect_to admin_procedures_draft_path
else
render json: {}, status: 403
end
end
def archive
procedure = current_administrateur.procedures.find(params[:procedure_id])
procedure.close!
@ -92,56 +51,9 @@ class Admin::ProceduresController < AdminController
render layout: 'application'
end
def active_class
@active_class = 'active'
end
def archived_class
@archived_class = 'active'
end
def draft_class
@draft_class = 'active'
end
def delete_logo
@procedure.logo.purge_later
flash.notice = 'le logo a bien été supprimé'
redirect_to edit_admin_procedure_path(@procedure)
end
def delete_deliberation
@procedure.deliberation.purge_later
flash.notice = 'la délibération a bien été supprimée'
redirect_to edit_admin_procedure_path(@procedure)
end
def delete_notice
@procedure.notice.purge_later
flash.notice = 'la notice a bien été supprimée'
redirect_to edit_admin_procedure_path(@procedure)
end
private
def cloned_from_library?
params[:from_new_from_existing].present?
end
def publish_params
params.permit(:path, :lien_site_web)
end
def procedure_params
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :euro_flag, :logo, :auto_archive_on]
permited_params = if @procedure&.locked?
params.require(:procedure).permit(*editable_params)
else
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :path)
end
permited_params
end
end

View file

@ -193,17 +193,11 @@ Rails.application.routes.draw do
get 'procedures/archived', to: redirect('/admin/procedures?statut=archivees')
get 'procedures/draft', to: redirect('/admin/procedures?statut=brouillons')
resources :procedures, only: [:destroy] do
resources :procedures, only: [] do
collection do
get 'new_from_existing' => 'procedures#new_from_existing', as: :new_from_existing
end
member do
delete :delete_logo
delete :delete_deliberation
delete :delete_notice
end
put 'archive' => 'procedures#archive', as: :archive
put 'clone' => 'procedures#clone', as: :clone
end

View file

@ -35,12 +35,6 @@ describe Admin::ProceduresController, type: :controller do
sign_in(admin.user)
end
describe 'GET #published' do
subject { get :published }
it { expect(response.status).to eq(200) }
end
describe 'DELETE #destroy' do
let(:procedure_draft) { create(:procedure, administrateurs: [admin]) }
let(:procedure_published) { create(:procedure, :published, administrateurs: [admin]) }
@ -227,54 +221,4 @@ describe Admin::ProceduresController, type: :controller do
end
end
end
describe "DELETE #delete_deliberation" do
context "with a demarche the admin owns" do
let(:procedure) { create(:procedure, :with_deliberation, administrateur: admin) }
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
context "with a demarche the admin does not own" do
let(:procedure) { create(:procedure, :with_deliberation) }
before do
delete :delete_deliberation, params: { id: procedure.id }
procedure.reload
end
it { expect(response.status).to eq(404) }
end
end
describe "DELETE #delete_notice" do
context "with a demarche the admin owns" do
let(:procedure) { create(:procedure, :with_notice, administrateur: admin) }
before do
delete :delete_notice, params: { id: procedure.id }
procedure.reload
end
it { expect(procedure.notice.attached?).to eq(false) }
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) }
end
context "with a demarche the admin does not own" do
let(:procedure) { create(:procedure, :with_notice) }
before do
delete :delete_notice, params: { id: procedure.id }
procedure.reload
end
it { expect(response.status).to eq(404) }
end
end
end