refactor(avis): remove unused controller action

This commit is contained in:
Paul Chavard 2022-04-19 09:40:45 +02:00
parent 004c9f6e18
commit 009c44cc20
3 changed files with 0 additions and 64 deletions

View file

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

View file

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

View file

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