Exclude notification for dossier state draft and for accompagnateur comments

This commit is contained in:
Xavier J 2016-12-26 14:38:00 +01:00
parent 33362d1a52
commit 9a0a391c40
6 changed files with 21 additions and 5 deletions

View file

@ -24,6 +24,8 @@ class Cerfa < ActiveRecord::Base
private
def internal_notification
unless dossier.state == 'draft'
NotificationService.new('cerfa', self.dossier.id).notify
end
end
end

View file

@ -52,6 +52,8 @@ class Champ < ActiveRecord::Base
private
def internal_notification
unless dossier.state == 'draft'
NotificationService.new('champs', self.dossier.id, self.libelle).notify
end
end
end

View file

@ -13,6 +13,8 @@ class Commentaire < ActiveRecord::Base
private
def internal_notification
if email == dossier.user.email || dossier.invites.pluck(:email).to_a.include?(email)
NotificationService.new('commentaire', self.dossier.id).notify
end
end
end

View file

@ -49,6 +49,8 @@ class PieceJustificative < ActiveRecord::Base
private
def internal_notification
unless self.type_de_piece_justificative.nil? && dossier.state == 'draft'
NotificationService.new('piece_justificative', self.dossier.id, self.libelle).notify
end
end
end

View file

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

View file

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