mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
DEV: Add a test to ensure that our SMTP settings are correct (#26410)
Why this change? This is a follow up to 897be75941eb95b89e885e4b447ddf0c75eb81ff. When updating `net-smtp` from `0.4.x` to `0.5.x`, our test suite passed but the error `ArgumentError: SMTP-AUTH requested but missing user name` was being thrown in production leading to emails being failed to send out via SMTP. This commit adds a test to ensure that our production SMTP settings will at least attemp to connect to an SMTP server.
This commit is contained in:

committed by
GitHub

parent
69c132723f
commit
69af29cc40
28
spec/integration/smtp_spec.rb
Normal file
28
spec/integration/smtp_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "SMTP Settings Integration" do
|
||||
before do
|
||||
@original_action_mailer_smtp_settings = ActionMailer::Base.smtp_settings
|
||||
@original_action_mailer_delivery_method = ActionMailer::Base.delivery_method
|
||||
ActionMailer::Base.delivery_method = :smtp
|
||||
end
|
||||
|
||||
after do
|
||||
ActionMailer::Base.smtp_settings = @original_action_mailer_smtp_settings
|
||||
ActionMailer::Base.delivery_method = @original_action_mailer_delivery_method
|
||||
end
|
||||
|
||||
it "should send out the email successfully using the SMTP settings" do
|
||||
global_setting :smtp_address, "some.host"
|
||||
global_setting :smtp_port, 12_345
|
||||
|
||||
ActionMailer::Base.smtp_settings = GlobalSetting.smtp_settings
|
||||
|
||||
message = TestMailer.send_test("some_email")
|
||||
|
||||
expect do Email::Sender.new(message, :test_message).send end.to raise_error(
|
||||
StandardError,
|
||||
/some.host/,
|
||||
)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user