feat: Notification on new messages in conversation (#1204)
fixes: #895 fixes: #1118 fixes: #1075 Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
co-authored by
Pranav Raj S
parent
3b92c744d6
commit
31c07771e8
@@ -69,7 +69,7 @@ RSpec.describe Conversation, type: :model do
|
||||
conversation.update(
|
||||
status: :resolved,
|
||||
locked: true,
|
||||
user_last_seen_at: Time.now,
|
||||
contact_last_seen_at: Time.now,
|
||||
assignee: new_assignee
|
||||
)
|
||||
end
|
||||
@@ -317,7 +317,7 @@ RSpec.describe Conversation, type: :model do
|
||||
timestamp: conversation.created_at.to_i,
|
||||
can_reply: true,
|
||||
channel: 'Channel::WebWidget',
|
||||
user_last_seen_at: conversation.user_last_seen_at.to_i,
|
||||
contact_last_seen_at: conversation.contact_last_seen_at.to_i,
|
||||
agent_last_seen_at: conversation.agent_last_seen_at.to_i,
|
||||
unread_count: 0
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ RSpec.describe Message, type: :model do
|
||||
end
|
||||
|
||||
context 'when message is created' do
|
||||
let(:message) { build(:message) }
|
||||
let(:message) { build(:message, account: create(:account)) }
|
||||
|
||||
it 'triggers ::MessageTemplates::HookExecutionService' do
|
||||
hook_execution_service = double
|
||||
@@ -23,10 +23,25 @@ RSpec.describe Message, type: :model do
|
||||
expect(hook_execution_service).to have_received(:perform)
|
||||
end
|
||||
|
||||
it 'calls notify email method on after save' do
|
||||
allow(message).to receive(:notify_via_mail).and_return(true)
|
||||
it 'calls notify email method on after save for outgoing messages' do
|
||||
allow(ConversationReplyEmailWorker).to receive(:perform_in).and_return(true)
|
||||
message.message_type = 'outgoing'
|
||||
message.save!
|
||||
expect(message).to have_received(:notify_via_mail)
|
||||
expect(ConversationReplyEmailWorker).to have_received(:perform_in)
|
||||
end
|
||||
|
||||
it 'wont call notify email method for private notes' do
|
||||
message.private = true
|
||||
allow(ConversationReplyEmailWorker).to receive(:perform_in).and_return(true)
|
||||
message.save!
|
||||
expect(ConversationReplyEmailWorker).not_to have_received(:perform_in)
|
||||
end
|
||||
|
||||
it 'wont call notify email method unless its website or email channel' do
|
||||
message.inbox = create(:inbox, account: message.account, channel: build(:channel_api, account: message.account))
|
||||
allow(ConversationReplyEmailWorker).to receive(:perform_in).and_return(true)
|
||||
message.save!
|
||||
expect(ConversationReplyEmailWorker).not_to have_received(:perform_in)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user