Exclude notification for dossier state draft and for accompagnateur comments
This commit is contained in:
parent
33362d1a52
commit
9a0a391c40
6 changed files with 21 additions and 5 deletions
|
@ -24,6 +24,8 @@ class Cerfa < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def internal_notification
|
||||
NotificationService.new('cerfa', self.dossier.id).notify
|
||||
unless dossier.state == 'draft'
|
||||
NotificationService.new('cerfa', self.dossier.id).notify
|
||||
end
|
||||
end
|
||||
end
|
|
@ -52,6 +52,8 @@ class Champ < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def internal_notification
|
||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||
unless dossier.state == 'draft'
|
||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,8 @@ class Commentaire < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def internal_notification
|
||||
NotificationService.new('commentaire', self.dossier.id).notify
|
||||
if email == dossier.user.email || dossier.invites.pluck(:email).to_a.include?(email)
|
||||
NotificationService.new('commentaire', self.dossier.id).notify
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,6 +49,8 @@ class PieceJustificative < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def internal_notification
|
||||
NotificationService.new('piece_justificative', self.dossier.id, self.libelle).notify
|
||||
unless self.type_de_piece_justificative.nil? && dossier.state == 'draft'
|
||||
NotificationService.new('piece_justificative', self.dossier.id, self.libelle).notify
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,6 +36,10 @@ describe Backoffice::CommentairesController, type: :controller do
|
|||
expect { subject }.to change(Follow, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
it 'Internal notification is not create' do
|
||||
expect { subject }.to change(Notification, :count).by (0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when document is upload whith a commentaire', vcr: {cassette_name: 'controllers_backoffice_commentaires_controller_doc_upload_with_comment'} do
|
||||
|
@ -54,6 +58,10 @@ describe Backoffice::CommentairesController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it 'Internal notification is not create' do
|
||||
expect { subject }.to change(Notification, :count).by (0)
|
||||
end
|
||||
|
||||
describe 'piece justificative created' do
|
||||
let(:pj) { PieceJustificative.last }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
sequence(:gestionnaire_email) { |n| "plop#{n}@plop.com" }
|
||||
sequence(:gestionnaire_email) { |n| "gest#{n}@plop.com" }
|
||||
factory :gestionnaire do
|
||||
email { generate(:gestionnaire_email) }
|
||||
password 'password'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue