feat: Clear all previous notifications if a new notification is added to a conversation (#8490)

This commit is contained in:
Muhsin Keloth
2023-12-06 14:03:43 +05:30
committed by GitHub
parent 76711d95ff
commit db33b7d1dc
6 changed files with 57 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
require 'rails_helper'
RSpec.describe Notification::RemoveDuplicateNotificationJob do
let(:user) { create(:user) }
let(:conversation) { create(:conversation) }
it 'enqueues the job' do
duplicate_notification = create(:notification, user: user, notification_type: 'conversation_creation', primary_actor: conversation)
expect do
described_class.perform_later(duplicate_notification)
end.to have_enqueued_job(described_class)
.on_queue('default')
end
it 'removes duplicate notifications' do
create(:notification, user: user, notification_type: 'conversation_creation', primary_actor: conversation)
duplicate_notification = create(:notification, user: user, notification_type: 'conversation_creation', primary_actor: conversation)
described_class.perform_now(duplicate_notification)
expect(Notification.count).to eq(1)
end
end