Add notifications when user post a comment

This commit is contained in:
Xavier J 2016-12-22 20:40:23 +01:00
parent ce5b75a0b9
commit 54fbe367c0
6 changed files with 94 additions and 7 deletions

View file

@ -0,0 +1,29 @@
require 'spec_helper'
describe NotificationService do
describe '.notify' do
let(:dossier) { create :dossier }
let(:service) { described_class.new type_notif, dossier.id }
subject { service.notify }
context 'when is the first notification for dossier_id and type_notif and alread_read is false' do
let(:type_notif) { 'commentaire' }
it { expect { subject }.to change(Notification, :count).by (1) }
context 'when is not the first notification' do
before do
create :notification, dossier: dossier, type_notif: type_notif
end
it { expect { subject }.to change(Notification, :count).by (0) }
end
end
end
describe 'text_for_notif' do
pending
end
end