diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-30 21:10:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-30 21:10:26 +0300 |
commit | a283b2d9d06e6b85ed0883e4cf81c5dc3c3ab3e3 (patch) | |
tree | d82ece86345466253949dede28503cd92e241e9a /spec/initializers | |
parent | faa68a02897b496a75bef827817866cdd775cd79 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/initializers')
-rw-r--r-- | spec/initializers/mail_starttls_patch_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/initializers/mail_starttls_patch_spec.rb b/spec/initializers/mail_starttls_patch_spec.rb index 99c8edddd12..0ceeb78a5b8 100644 --- a/spec/initializers/mail_starttls_patch_spec.rb +++ b/spec/initializers/mail_starttls_patch_spec.rb @@ -17,6 +17,37 @@ RSpec.describe 'Mail STARTTLS patch', feature_category: :shared do end end + # As long as this monkey patch exists and overrides the constructor + # we should test that the defaults of Mail::SMTP are not overriden. + # + # @see issue https://gitlab.com/gitlab-org/gitlab/-/issues/423268 + # @see incident https://gitlab.com/gitlab-com/gl-infra/production/-/issues/16223 + it 'does not override default constants values' do + expected_settings = Mail::SMTP.new({}).settings.dup + + Mail.new.delivery_method(Mail::SMTP, { user_name: 'user@example.com' }) + + expect(Mail::SMTP.new({}).settings).to eq(expected_settings) + end + + describe 'enable_starttls_auto setting' do + let(:settings) { {} } + + subject(:smtp) { Mail::SMTP.new(settings) } + + it 'uses default for enable_starttls_auto' do + expect(smtp.settings).to include(enable_starttls_auto: nil) + end + + context 'when set to false' do + let(:settings) { { enable_starttls_auto: false } } + + it 'overrides default and sets value' do + expect(smtp.settings).to include(enable_starttls_auto: false) + end + end + end + # Taken from https://github.com/mikel/mail/pull/1536#issue-1490438378 where(:ssl, :tls, :enable_starttls, :enable_starttls_auto, :smtp_tls, :smtp_starttls_mode) do true | nil | nil | nil | true | false |