chore: Prevent notification email loop (#3386)

Configuring an agent email also as a support email inbox leads to conversations getting created in a loop if notifications were also configured to the same email.
This commit is contained in:
Sojan Jose
2021-11-15 19:15:51 +05:30
committed by GitHub
parent e849759e15
commit acb06e7df6
4 changed files with 190 additions and 0 deletions

View File

@@ -3,6 +3,19 @@ require 'rails_helper'
RSpec.describe SupportMailbox, type: :mailbox do
include ActionMailbox::TestHelper
describe 'when a chatwoot notification email is received' do
let(:account) { create(:account) }
let!(:channel_email) { create(:channel_email, email: 'sojan@chatwoot.com', account: account) }
let(:notification_mail) { create_inbound_email_from_fixture('notification.eml') }
let(:described_subject) { described_class.receive notification_mail }
let(:conversation) { Conversation.where(inbox_id: channel_email.inbox).last }
it 'shouldnt create a conversation in the channel' do
described_subject
expect(conversation.present?).to eq(false)
end
end
describe 'add mail as a new ticket in the email inbox' do
let(:account) { create(:account) }
let(:agent) { create(:user, email: 'agent1@example.com', account: account) }