mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
require 'action_mailer_configs_interceptor'
|
|
|
|
RSpec.describe ActionMailerConfigsInterceptor do
|
|
let(:message) do
|
|
Mail.new do
|
|
to 'user@example.com'
|
|
from 'sender@example.com'
|
|
subject 'Hi'
|
|
body 'Hello'
|
|
end
|
|
end
|
|
|
|
describe '.delivering_email' do
|
|
before { allow(Rails.env).to receive(:production?).and_return(true) }
|
|
|
|
it 'applies env SMTP settings when ExternalConfig.smtp_configured?' do
|
|
envs = {
|
|
'DOCUSEAL_CONFIG_SMTP_ADDRESS' => 'smtp.example.com',
|
|
'DOCUSEAL_CONFIG_SMTP_PORT' => '2525',
|
|
'DOCUSEAL_CONFIG_SMTP_USERNAME' => 'user',
|
|
'DOCUSEAL_CONFIG_SMTP_PASSWORD' => 'secret'
|
|
}
|
|
with_env(envs) do
|
|
described_class.delivering_email(message)
|
|
method = message.delivery_method
|
|
expect(method.settings[:address]).to eq('smtp.example.com')
|
|
expect(method.settings[:port]).to eq(2525)
|
|
expect(method.settings[:user_name]).to eq('user')
|
|
end
|
|
end
|
|
|
|
it 'does not use env SMTP settings when env is absent' do
|
|
with_env('DOCUSEAL_CONFIG_SMTP_ADDRESS' => nil) do
|
|
# Falls through to the legacy branches; we only assert it did not pick env settings.
|
|
described_class.delivering_email(message)
|
|
method = message.delivery_method
|
|
expect(method.settings[:address]).not_to eq('smtp.example.com')
|
|
end
|
|
end
|
|
end
|
|
end
|