feat: Clear all previous notifications if a new notification is added to a conversation (#8490)
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user