test fonctionnel notifications commentaire

This commit is contained in:
clemkeirua 2020-09-07 15:37:40 +02:00 committed by Keirua (Rebase PR Action)
parent c7b96d3d43
commit 1fafcad401

View file

@ -834,6 +834,8 @@ describe Users::DossiersController, type: :controller do
before do
Timecop.freeze(now)
sign_in(user)
# Flipper.enable(:cached_notifications, instructeur_with_instant_message)
# Flipper.enable(:cached_notifications, instructeur_without_instant_message)
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
allow(DossierMailer).to receive(:notify_new_commentaire_to_instructeur).and_return(double(deliver_later: nil))
instructeur_with_instant_message.follow(dossier)
@ -844,6 +846,7 @@ describe Users::DossiersController, type: :controller do
after { Timecop.return }
context 'commentaire creation' do
it "creates a commentaire" do
expect { subject }.to change(Commentaire, :count).by(1)
@ -855,6 +858,21 @@ describe Users::DossiersController, type: :controller do
end
end
context 'notification' do
before 'instructeurs have no notification before the message' do
expect(instructeur_with_instant_message.followed_dossiers.with_notifications(instructeur_with_instant_message)).to eq([])
expect(instructeur_without_instant_message.followed_dossiers.with_notifications(instructeur_without_instant_message)).to eq([])
Timecop.travel(now + 1.day)
subject
end
it 'adds them a notification' do
expect(instructeur_with_instant_message.reload.followed_dossiers.with_notifications(instructeur_with_instant_message)).to eq([dossier.reload])
expect(instructeur_without_instant_message.reload.followed_dossiers.with_notifications(instructeur_without_instant_message)).to eq([dossier.reload])
end
end
end
describe '#ask_deletion' do
before { sign_in(user) }