feat: Tag agents in a private note (#1688)
Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -43,4 +43,37 @@ describe NotificationListener do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'message_created' do
|
||||
let(:event_name) { :'message.created' }
|
||||
|
||||
context 'when message contains mention' do
|
||||
it 'creates notifications for inbox member who was mentioned' do
|
||||
notification_setting = agent_with_notification.notification_settings.find_by(account_id: account.id)
|
||||
notification_setting.selected_email_flags = [:email_conversation_mention]
|
||||
notification_setting.selected_push_flags = []
|
||||
notification_setting.save!
|
||||
|
||||
builder = double
|
||||
allow(NotificationBuilder).to receive(:new).and_return(builder)
|
||||
allow(builder).to receive(:perform)
|
||||
|
||||
create(:inbox_member, user: agent_with_notification, inbox: inbox)
|
||||
create(:inbox_member, user: agent_with_out_notification, inbox: inbox)
|
||||
conversation.reload
|
||||
|
||||
message = build(:message, conversation: conversation, account: account,
|
||||
content: "hi [#{agent_with_notification.name}](mention://user/#{agent_with_notification.id}/\
|
||||
#{agent_with_notification.name})", private: true)
|
||||
|
||||
event = Events::Base.new(event_name, Time.zone.now, message: message)
|
||||
listener.message_created(event)
|
||||
|
||||
expect(NotificationBuilder).to have_received(:new).with(notification_type: 'conversation_mention',
|
||||
user: agent_with_notification,
|
||||
account: account,
|
||||
primary_actor: message)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,9 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :mailer do
|
||||
let(:class_instance) { described_class.new }
|
||||
let(:agent) { create(:user, email: 'agent1@example.com') }
|
||||
let(:conversation) { create(:conversation, assignee: agent) }
|
||||
let!(:account) { create(:account) }
|
||||
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }
|
||||
let(:conversation) { create(:conversation, assignee: agent, account: account) }
|
||||
|
||||
before do
|
||||
allow(described_class).to receive(:new).and_return(class_instance)
|
||||
@@ -37,6 +38,19 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile
|
||||
end
|
||||
end
|
||||
|
||||
describe 'conversation_mention' do
|
||||
let(:message) { create(:message, conversation: conversation, account: account) }
|
||||
let(:mail) { described_class.conversation_mention(message, agent).deliver_now }
|
||||
|
||||
it 'renders the subject' do
|
||||
expect(mail.subject).to eq("#{agent.available_name}, You have been mentioned in conversation [ID - #{conversation.display_id}]")
|
||||
end
|
||||
|
||||
it 'renders the receiver email' do
|
||||
expect(mail.to).to eq([agent.email])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'assigned_conversation_new_message' do
|
||||
let(:mail) { described_class.assigned_conversation_new_message(conversation, agent).deliver_now }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user