fixes
This commit is contained in:
@@ -95,17 +95,13 @@ class Notification < ApplicationRecord
|
||||
def push_message_title
|
||||
case notification_type
|
||||
when 'conversation_creation'
|
||||
I18n.t('notifications.notification_title.conversation_creation', display_id: conversation.display_id, inbox_name: primary_actor.inbox.name)
|
||||
conversation_creation_message_content
|
||||
when 'conversation_assignment'
|
||||
I18n.t('notifications.notification_title.conversation_assignment', display_id: conversation.display_id)
|
||||
when 'assigned_conversation_new_message', 'participating_conversation_new_message'
|
||||
I18n.t(
|
||||
'notifications.notification_title.assigned_conversation_new_message',
|
||||
display_id: conversation.display_id,
|
||||
content: content
|
||||
)
|
||||
message_created_message_content
|
||||
when 'conversation_mention'
|
||||
"[##{conversation&.display_id}] #{transform_user_mention_content content}"
|
||||
mention_content
|
||||
else
|
||||
''
|
||||
end
|
||||
@@ -116,11 +112,11 @@ class Notification < ApplicationRecord
|
||||
end
|
||||
|
||||
def conversation_creation_message_content
|
||||
"#{conversation.messages.first&.sender&.name}: #{conversation.messages.first&.content}"
|
||||
"#{conversation.messages.first&.sender&.name}: #{content}"
|
||||
end
|
||||
|
||||
def message_created_message_content
|
||||
"#{secondary_actor&.sender&.name}: #{secondary_actor&.content}"
|
||||
"#{secondary_actor&.sender&.name}: #{content}"
|
||||
end
|
||||
|
||||
def mention_content
|
||||
|
||||
@@ -23,9 +23,10 @@ RSpec.describe Notification do
|
||||
|
||||
context 'when push_title is called' do
|
||||
it 'returns appropriate title suited for the notification type conversation_creation' do
|
||||
notification = create(:notification, notification_type: 'conversation_creation')
|
||||
expect(notification.push_message_title).to eq "[New conversation] - ##{notification.primary_actor.display_id} has\
|
||||
been created in #{notification.primary_actor.inbox.name}"
|
||||
conversation = create(:conversation)
|
||||
message = create(:message, sender: create(:user), content: Faker::Lorem.paragraphs(number: 2), conversation: conversation)
|
||||
notification = create(:notification, notification_type: 'conversation_creation', primary_actor: conversation)
|
||||
expect(notification.push_message_title).to eq "#{message.sender.name}: #{message.content}"
|
||||
end
|
||||
|
||||
it 'returns appropriate title suited for the notification type conversation_assignment' do
|
||||
@@ -39,8 +40,7 @@ RSpec.describe Notification do
|
||||
notification = create(:notification, notification_type: 'assigned_conversation_new_message', primary_actor: message.conversation,
|
||||
secondary_actor: message)
|
||||
|
||||
expect(notification.push_message_title).to eq "[New message] - ##{notification.conversation.display_id} \
|
||||
#{message.content.truncate_words(10)}"
|
||||
expect(notification.push_message_title).to eq "#{message.sender.name}: #{message.content.truncate_words(10)}"
|
||||
end
|
||||
|
||||
it 'returns appropriate title suited for the notification type assigned_conversation_new_message when attachment message' do
|
||||
@@ -100,8 +100,7 @@ Hey @John, @Alisha Peter can you check this ticket?"
|
||||
content: 'Hey [@John](mention://user/1/john), [@Alisha Peter](mention://user/2/alisha) 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, @Alisha Peter can you check this ticket?"
|
||||
expect(notification.push_message_title).to eq "#{message.sender.name}: Hey @John, @Alisha Peter can you check this ticket?"
|
||||
end
|
||||
|
||||
it 'returns appropriate title suited for the notification type conversation_mention if username contains white space' do
|
||||
@@ -111,7 +110,7 @@ Hey @John, @Alisha Peter can you check this ticket?"
|
||||
content: 'Hey [@John Peter](mention://user/1/john%20K) please check this?'
|
||||
)
|
||||
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?"
|
||||
expect(notification.push_message_title).to eq "#{message.sender.name}: Hey @John Peter please check this?"
|
||||
end
|
||||
|
||||
it 'calls remove duplicate notification job' do
|
||||
|
||||
Reference in New Issue
Block a user