discourse/spec/lib/freedom_patches/mail_disable_starttls_spec.rb
Loïc Guitaut fff3ff11c0 FIX: Make disabling TLS in mail possible again
Following the Rails 7 upgrade, the `DISCOURSE_SMTP_ENABLE_START_TLS`
setting doesn’t work anymore. This is because Rails upgraded the
`net-smtp` gem to the 0.3.1 version which enables `starttls` by default.
The `mail` gem doesn’t support this new behavior yet and doesn’t know
how to disable TLS. This should be fixed in an upcoming release.

Meanwhile applying this patch allows us to get back the previous
behavior which is expected by many.
2022-06-08 14:04:05 +02:00

24 lines
567 B
Ruby

# frozen_string_literal: true
describe FreedomPatches::MailDisableStarttls do
subject(:smtp_session) { smtp.build_smtp_session }
let(:smtp) { Mail::SMTP.new(options) }
context "when the starttls option is not provided" do
let(:options) { {} }
it "doesn't disable starttls" do
expect(smtp_session).to be_starttls
end
end
context "when the starttls option is set to `false`" do
let(:options) { { enable_starttls_auto: false } }
it "properly disables starttls" do
expect(smtp_session).not_to be_starttls
end
end
end