Commit 2a687a24 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix errors when using deliver!

This makes the SMTP pool delivery method compatible with #deliver!

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60843
parent c4ef6fee
---
title: Fix SMTP errors when delivering service desk thank you emails with SMTP pool
enabled
merge_request: 60843
author:
type: fixed
......@@ -38,7 +38,7 @@ module Gitlab
if from_address
add_email_participant
send_thank_you_email!
send_thank_you_email
end
end
......@@ -92,8 +92,8 @@ module Gitlab
end
end
def send_thank_you_email!
Notify.service_desk_thank_you_email(@issue.id).deliver_later!
def send_thank_you_email
Notify.service_desk_thank_you_email(@issue.id).deliver_later
end
def message_including_template
......
......@@ -90,11 +90,6 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do
context 'when quick actions are present' do
let(:label) { create(:label, project: project, title: 'label1') }
let(:milestone) { create(:milestone, project: project) }
let!(:user) { create(:user, username: 'user1') }
before do
project.add_developer(user)
end
it 'applies quick action commands present on templates' do
file_content = %(Text from template \n/label ~#{label.title} \n/milestone %"#{milestone.name}"")
......
......@@ -30,5 +30,11 @@ module Mail
def deliver!(mail)
@pool.with { |conn| conn.deliver!(mail) }
end
# This makes it compatible with Mail's `#deliver!` method
# https://github.com/mikel/mail/blob/22a7afc23f253319965bf9228a0a430eec94e06d/lib/mail/message.rb#L271
def settings
{}
end
end
end
......@@ -64,5 +64,27 @@ describe Mail::SMTPPool do
expect(MockSMTP.deliveries.size).to eq(1)
end
context 'when called from Mail:Message' do
before do
mail.delivery_method(described_class, { pool: described_class.create_pool })
end
describe '#deliver' do
it 'delivers mail' do
mail.deliver
expect(MockSMTP.deliveries.size).to eq(1)
end
end
describe '#deliver!' do
it 'delivers mail' do
mail.deliver!
expect(MockSMTP.deliveries.size).to eq(1)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment