Merge pull request #7055 from betagouv/feat/7054
ETQ Instructeur, lorsque l'usager a supprimé le dossier de son interface, je ne peux plus lui envoyer de messages
This commit is contained in:
commit
b72de3c64d
3 changed files with 16 additions and 2 deletions
|
@ -111,7 +111,7 @@ class Commentaire < ApplicationRecord
|
|||
def messagerie_available?
|
||||
return if sent_by_system?
|
||||
if dossier.present? && !dossier.messagerie_available?
|
||||
errors.add(:dossier, "Il n’est pas possible d’envoyer un message sur un dossier archivé ou en brouillon")
|
||||
errors.add(:dossier, "Il n’est pas possible d’envoyer un message sur un dossier supprimé, archivé ou en brouillon")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -528,7 +528,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def messagerie_available?
|
||||
!brouillon? && !user_deleted? && !archived
|
||||
visible_by_administration? && !hidden_by_user? && !user_deleted? && !archived
|
||||
end
|
||||
|
||||
def expirable?
|
||||
|
|
|
@ -457,6 +457,20 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
expect(flash.notice).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context "when the dossier is deleted by user" do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
before do
|
||||
dossier.update!(hidden_by_user_at: 1.hour.ago)
|
||||
subject
|
||||
end
|
||||
|
||||
it "does not create a commentaire" do
|
||||
expect { subject }.to change(Commentaire, :count).by(0)
|
||||
expect(flash.alert).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create_avis" do
|
||||
|
|
Loading…
Reference in a new issue