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

View File

@@ -142,7 +142,7 @@ describe ActionCableListener do
'notification.deleted',
{
account_id: notification.account_id,
notification: notification,
notification: notification.push_event_data,
unread_count: 1,
count: 1
}

View File

@@ -113,6 +113,12 @@ Hey @John, @Alisha Peter can you check this ticket?"
notification = create(:notification, notification_type: 'conversation_mention', primary_actor: message.conversation, secondary_actor: message)
expect(notification.push_message_title).to eq "[##{message.conversation.display_id}] Hey @John Peter please check this?"
end
it 'calls remove duplicate notification job' do
allow(Notification::RemoveDuplicateNotificationJob).to receive(:perform_later)
notification = create(:notification, notification_type: 'conversation_mention')
expect(Notification::RemoveDuplicateNotificationJob).to have_received(:perform_later).with(notification)
end
end
context 'when fcm push data' do