fix: Terminate IMAP connection after the job is complete (#9225)

This commit is contained in:
Pranav
2024-04-11 15:47:43 -07:00
committed by GitHub
parent 0477b8ca14
commit e8fe3c7c05
5 changed files with 21 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ RSpec.describe Imap::FetchEmailService do
allow(imap).to receive(:search).with(%w[SINCE 25-Oct-2020]).and_return([1])
allow(imap).to receive(:fetch).with([1], 'BODY.PEEK[HEADER]').and_return([email_header])
allow(imap).to receive(:fetch).with(1, 'RFC822').and_return([imap_fetch_mail])
allow(imap).to receive(:logout)
result = described_class.new(channel: imap_email_channel).perform
@@ -39,6 +40,7 @@ RSpec.describe Imap::FetchEmailService do
expect(imap).to have_received(:fetch).with([1], 'BODY.PEEK[HEADER]')
expect(imap).to have_received(:fetch).with(1, 'RFC822')
expect(logger).to have_received(:info).with("[IMAP::FETCH_EMAIL_SERVICE] Fetching mails from #{imap_email_channel.email}, found 1.")
expect(imap).to have_received(:logout)
end
end
@@ -51,6 +53,7 @@ RSpec.describe Imap::FetchEmailService do
allow(imap).to receive(:search).with(%w[SINCE 25-Oct-2020]).and_return([1])
allow(imap).to receive(:fetch).with([1], 'BODY.PEEK[HEADER]').and_return([email_header])
allow(imap).to receive(:logout)
result = described_class.new(channel: imap_email_channel).perform

View File

@@ -35,6 +35,7 @@ RSpec.describe Imap::MicrosoftFetchEmailService do
allow(imap).to receive(:search).with(%w[SINCE 25-Oct-2020]).and_return([1])
allow(imap).to receive(:fetch).with([1], 'BODY.PEEK[HEADER]').and_return([email_header])
allow(imap).to receive(:fetch).with(1, 'RFC822').and_return([imap_fetch_mail])
allow(imap).to receive(:logout)
result = described_class.new(channel: microsoft_channel).perform