Supprime la possibilité pour l'expert invité d'envoyer un message à l'usager
This commit is contained in:
parent
f4fa557aca
commit
6636b7f14c
5 changed files with 1 additions and 67 deletions
|
@ -6,7 +6,7 @@ module Instructeurs
|
||||||
before_action :check_if_avis_revoked, only: [:show]
|
before_action :check_if_avis_revoked, only: [:show]
|
||||||
before_action :redirect_if_no_sign_up_needed, only: [:sign_up]
|
before_action :redirect_if_no_sign_up_needed, only: [:sign_up]
|
||||||
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_instructeur]
|
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_instructeur]
|
||||||
before_action :set_avis_and_dossier, only: [:show, :instruction, :messagerie, :create_commentaire, :update]
|
before_action :set_avis_and_dossier, only: [:show, :instruction, :update]
|
||||||
|
|
||||||
A_DONNER_STATUS = 'a-donner'
|
A_DONNER_STATUS = 'a-donner'
|
||||||
DONNES_STATUS = 'donnes'
|
DONNES_STATUS = 'donnes'
|
||||||
|
@ -53,23 +53,6 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def messagerie
|
|
||||||
@commentaire = Commentaire.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_commentaire
|
|
||||||
@commentaire = CommentaireService.build(current_instructeur, avis.dossier, commentaire_params)
|
|
||||||
|
|
||||||
if @commentaire.save
|
|
||||||
@commentaire.dossier.update!(last_commentaire_updated_at: Time.zone.now)
|
|
||||||
flash.notice = "Message envoyé"
|
|
||||||
redirect_to messagerie_instructeur_avis_path(avis.procedure, avis)
|
|
||||||
else
|
|
||||||
flash.alert = @commentaire.errors.full_messages
|
|
||||||
render :messagerie
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_avis
|
def create_avis
|
||||||
@procedure = Procedure.find(params[:procedure_id])
|
@procedure = Procedure.find(params[:procedure_id])
|
||||||
if !feature_enabled_for?(:expert_not_allowed_to_invite, @procedure)
|
if !feature_enabled_for?(:expert_not_allowed_to_invite, @procedure)
|
||||||
|
|
|
@ -8,4 +8,3 @@
|
||||||
%ul.tabs
|
%ul.tabs
|
||||||
= dynamic_tab_item('Demande', instructeur_avis_path(avis.procedure, avis))
|
= dynamic_tab_item('Demande', instructeur_avis_path(avis.procedure, avis))
|
||||||
= dynamic_tab_item('Avis', instruction_instructeur_avis_path(avis.procedure, avis), notification: avis.answer.blank?)
|
= dynamic_tab_item('Avis', instruction_instructeur_avis_path(avis.procedure, avis), notification: avis.answer.blank?)
|
||||||
= dynamic_tab_item('Messagerie', messagerie_instructeur_avis_path(avis.procedure, avis))
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
- content_for(:title, "Messagerie · Dossier nº #{@dossier.id} (#{@dossier.owner_name})")
|
|
||||||
|
|
||||||
= render partial: 'header', locals: { avis: @avis, dossier: @dossier }
|
|
||||||
|
|
||||||
= render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, connected_user: current_instructeur, messagerie_seen_at: nil, new_commentaire: @commentaire, form_url: commentaire_instructeur_avis_path(@avis) }
|
|
|
@ -300,7 +300,6 @@ Rails.application.routes.draw do
|
||||||
get '', action: 'procedure', on: :collection, as: :procedure
|
get '', action: 'procedure', on: :collection, as: :procedure
|
||||||
member do
|
member do
|
||||||
get 'instruction'
|
get 'instruction'
|
||||||
get 'messagerie'
|
|
||||||
post 'commentaire' => 'avis#create_commentaire'
|
post 'commentaire' => 'avis#create_commentaire'
|
||||||
post 'avis' => 'avis#create_avis'
|
post 'avis' => 'avis#create_avis'
|
||||||
patch 'revoquer'
|
patch 'revoquer'
|
||||||
|
|
|
@ -65,14 +65,6 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#messagerie' do
|
|
||||||
before { get :messagerie, params: { id: avis_without_answer.id, procedure_id: procedure.id } }
|
|
||||||
|
|
||||||
it { expect(response).to have_http_status(:success) }
|
|
||||||
it { expect(assigns(:avis)).to eq(avis_without_answer) }
|
|
||||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#bilans_bdf' do
|
describe '#bilans_bdf' do
|
||||||
before { get :bilans_bdf, params: { id: avis_without_answer.id, procedure_id: procedure.id } }
|
before { get :bilans_bdf, params: { id: avis_without_answer.id, procedure_id: procedure.id } }
|
||||||
|
|
||||||
|
@ -118,40 +110,6 @@ describe Instructeurs::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create_commentaire' do
|
|
||||||
let(:file) { nil }
|
|
||||||
let(:scan_result) { true }
|
|
||||||
let(:now) { Time.zone.parse("14/07/1789") }
|
|
||||||
|
|
||||||
subject { post :create_commentaire, params: { id: avis_without_answer.id, procedure_id: procedure.id, commentaire: { body: 'commentaire body', piece_jointe: file } } }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
|
|
||||||
Timecop.freeze(now)
|
|
||||||
end
|
|
||||||
|
|
||||||
after { Timecop.return }
|
|
||||||
|
|
||||||
it do
|
|
||||||
subject
|
|
||||||
|
|
||||||
expect(response).to redirect_to(messagerie_instructeur_avis_path(avis_without_answer.procedure, avis_without_answer))
|
|
||||||
expect(dossier.commentaires.map(&:body)).to match(['commentaire body'])
|
|
||||||
expect(dossier.reload.last_commentaire_updated_at).to eq(now)
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with a file" do
|
|
||||||
let(:file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
|
|
||||||
|
|
||||||
it do
|
|
||||||
subject
|
|
||||||
expect(Commentaire.last.piece_jointe.filename).to eq("piece_justificative_0.pdf")
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect { subject }.to change(Commentaire, :count).by(1) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#expert_cannot_invite_another_expert' do
|
describe '#expert_cannot_invite_another_expert' do
|
||||||
let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, instructeur: instructeur, confidentiel: previous_avis_confidentiel) }
|
let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, instructeur: instructeur, confidentiel: previous_avis_confidentiel) }
|
||||||
let(:previous_avis_confidentiel) { false }
|
let(:previous_avis_confidentiel) { false }
|
||||||
|
|
Loading…
Reference in a new issue