From 009c44cc20bb598c9b4363f625702ca4f96d3496 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 19 Apr 2022 09:40:45 +0200 Subject: [PATCH] refactor(avis): remove unused controller action --- app/controllers/experts/avis_controller.rb | 16 ------- config/routes.rb | 1 - .../messages/message.html.haml_spec.rb | 47 ------------------- 3 files changed, 64 deletions(-) diff --git a/app/controllers/experts/avis_controller.rb b/app/controllers/experts/avis_controller.rb index a298d4485..35ff9c99d 100644 --- a/app/controllers/experts/avis_controller.rb +++ b/app/controllers/experts/avis_controller.rb @@ -113,22 +113,6 @@ module Experts end end - def delete_commentaire - commentaire = avis.dossier.commentaires.find(params[:commentaire]) - if commentaire.sent_by?(current_expert) - commentaire.piece_jointe.purge_later if commentaire.piece_jointe.attached? - commentaire.discard! - commentaire.update!(body: '') - flash[:notice] = t('views.shared.commentaires.destroy.notice') - else - flash[:alert] = I18n.t('views.shared.commentaires.destroy.alert_reasons.acl') - end - redirect_to(messagerie_expert_avis_path(avis.procedure, avis)) - rescue Discard::RecordNotDiscarded - flash[:alert] = I18n.t('views.shared.commentaires.destroy.alert_reasons.already_discarded') - redirect_to(messagerie_expert_avis_path(avis.procedure, avis)) - end - def bilans_bdf if avis.dossier.etablissement&.entreprise_bilans_bdf.present? extension = params[:format] diff --git a/config/routes.rb b/config/routes.rb index 4dc41112c..655a3247e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -310,7 +310,6 @@ Rails.application.routes.draw do get 'instruction' get 'messagerie' post 'commentaire' => 'avis#create_commentaire' - delete 'delete_commentaire' => 'avis#delete_commentaire' post 'avis' => 'avis#create_avis' get 'bilans_bdf' get 'telecharger_pjs' => 'avis#telecharger_pjs' diff --git a/spec/views/shared/dossiers/messages/message.html.haml_spec.rb b/spec/views/shared/dossiers/messages/message.html.haml_spec.rb index 106b11178..00744a27a 100644 --- a/spec/views/shared/dossiers/messages/message.html.haml_spec.rb +++ b/spec/views/shared/dossiers/messages/message.html.haml_spec.rb @@ -86,51 +86,4 @@ describe 'shared/dossiers/messages/message.html.haml', type: :view do end end end - - context 'with an expert message' do - describe 'delete message button for expert' do - let(:expert) { create(:expert) } - let(:procedure) { create(:procedure) } - let(:dossier) { create(:dossier, :en_construction, commentaires: [commentaire], procedure: procedure) } - let(:experts_procedure) { create(:experts_procedure, procedure: procedure, expert: expert) } - let!(:avis) { create(:avis, email: nil, experts_procedure: experts_procedure) } - subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: expert, show_reply_button: true } - let(:form_url) { delete_commentaire_expert_avis_path(avis.procedure, avis, commentaire: commentaire) } - - before do - assign(:avis, avis) - end - - context 'on a procedure where commentaire had been written by connected expert' do - let(:commentaire) { create(:commentaire, expert: expert, body: 'Second message') } - - it { is_expected.to have_selector("form[action=\"#{form_url}\"]") } - end - - context 'on a procedure where commentaire had been written by connected expert and discarded' do - let(:commentaire) { create(:commentaire, expert: expert, body: 'Second message', discarded_at: 2.days.ago) } - - it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") } - it { is_expected.not_to have_selector(".rich-text", text: I18n.t(t('views.shared.commentaires.destroy.deleted_body'))) } - end - - context 'on a procedure where commentaire had been written by connected an user' do - let(:commentaire) { create(:commentaire, email: create(:user).email, body: 'Second message') } - - it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") } - end - - context 'on a procedure where commentaire had been written by connected an instructeur' do - let(:commentaire) { create(:commentaire, instructeur: create(:instructeur), body: 'Second message') } - - it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") } - end - - context 'on a procedure where commentaire had been written another expert' do - let(:commentaire) { create(:commentaire, expert: create(:expert), body: 'Second message') } - - it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") } - end - end - end end