mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Add optional bulk mailer settings (#35203)
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mastodon::EmailConfigurationHelper do
|
||||
describe '#smtp_settings' do
|
||||
describe '#convert_smtp_settings' do
|
||||
subject { described_class }
|
||||
|
||||
let(:converted_settings) { subject.smtp_settings(configuration) }
|
||||
let(:converted_settings) { subject.convert_smtp_settings(configuration) }
|
||||
let(:base_configuration) do
|
||||
{
|
||||
address: 'localhost',
|
||||
|
||||
@@ -103,4 +103,9 @@ class UserMailerPreview < ActionMailer::Preview
|
||||
def terms_of_service_changed
|
||||
UserMailer.terms_of_service_changed(User.first, TermsOfService.live.first)
|
||||
end
|
||||
|
||||
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/announcement_published
|
||||
def announcement_published
|
||||
UserMailer.announcement_published(User.first, Announcement.last)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,6 +14,43 @@ RSpec.describe UserMailer do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'optional bulk mailer settings' do
|
||||
context 'when no optional bulk mailer settings are present' do
|
||||
it 'does not include delivery method options' do
|
||||
expect(mail.message.delivery_method.settings).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'when optional bulk mailer settings are present' do
|
||||
let(:smtp_settings) do
|
||||
{
|
||||
address: 'localhost',
|
||||
port: 25,
|
||||
authentication: 'none',
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
Rails.configuration.x.email ||= ActiveSupport::OrderedOptions.new
|
||||
Rails.configuration.x.email.update({ bulk_mail: { smtp_settings: } })
|
||||
end
|
||||
|
||||
after do
|
||||
Rails.configuration.x.email = nil
|
||||
end
|
||||
|
||||
it 'uses the bulk mailer settings' do
|
||||
expect(mail.message.delivery_method.settings).to eq({
|
||||
address: 'localhost',
|
||||
port: 25,
|
||||
authentication: nil,
|
||||
enable_starttls: nil,
|
||||
enable_starttls_auto: true,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:receiver) { Fabricate(:user) }
|
||||
|
||||
describe '#confirmation_instructions' do
|
||||
@@ -316,6 +353,8 @@ RSpec.describe UserMailer do
|
||||
.and(have_subject(I18n.t('user_mailer.terms_of_service_changed.subject')))
|
||||
.and(have_body_text(I18n.t('user_mailer.terms_of_service_changed.changelog')))
|
||||
end
|
||||
|
||||
it_behaves_like 'optional bulk mailer settings'
|
||||
end
|
||||
|
||||
describe '#announcement_published' do
|
||||
@@ -328,5 +367,7 @@ RSpec.describe UserMailer do
|
||||
.and(have_subject(I18n.t('user_mailer.announcement_published.subject')))
|
||||
.and(have_body_text(I18n.t('user_mailer.announcement_published.description', domain: local_domain_uri.host)))
|
||||
end
|
||||
|
||||
it_behaves_like 'optional bulk mailer settings'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user