Revert dynamic email config changes (#13983)

* Add missing clear_cache in spec

* Fix broken spec

* Temporarily bring back old config

* Disable specs
This commit is contained in:
Mac Siri 2021-06-14 13:08:24 -04:00 committed by GitHub
parent ffc0bcd345
commit aba6033d9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 5 deletions

View file

@ -8,8 +8,10 @@ class ApplicationMailer < ActionMailer::Base
helper AuthenticationHelper
before_action :use_custom_host
before_action :set_delivery_options
before_action :set_perform_deliveries
# [@SRE] temporarily disabled
# before_action :set_delivery_options
# before_action :set_perform_deliveries
default(
from: -> { email_from },

View file

@ -127,8 +127,27 @@ Rails.application.configure do
protocol = ENV["APP_PROTOCOL"] || "http://"
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = false
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: protocol + ENV["APP_DOMAIN"].to_s }
ActionMailer::Base.smtp_settings = if ENV["SENDGRID_API_KEY"].present?
{
address: "smtp.sendgrid.net",
port: 587,
authentication: :plain,
user_name: "apikey",
password: ENV["SENDGRID_API_KEY"],
domain: ENV["APP_DOMAIN"]
}
else
{
address: ENV["SMTP_ADDRESS"],
port: ENV["SMTP_PORT"],
authentication: ENV["SMTP_AUTHENTICATION"],
user_name: ENV["SMTP_USER_NAME"],
password: ENV["SMTP_PASSWORD"],
domain: ENV["SMTP_DOMAIN"]
}
end
if ENV["HEROKU_APP_URL"].present? && ENV["HEROKU_APP_URL"] != ENV["APP_DOMAIN"]
config.middleware.use Rack::HostRedirect,

View file

@ -4,7 +4,7 @@ RSpec.describe ApplicationMailer, type: :mailer do
let(:user) { create(:user) }
let(:email) { VerificationMailer.with(user_id: user.id).account_ownership_verification_email }
describe "#set_perform_deliveries" do
xdescribe "#set_perform_deliveries" do
it "changes perform_deliveries from true to false if smtp is not enabled" do
expect { email.deliver_now }.to change(described_class, :perform_deliveries).from(true).to(false)
end
@ -17,7 +17,7 @@ RSpec.describe ApplicationMailer, type: :mailer do
end
end
describe "#set_delivery_options" do
xdescribe "#set_delivery_options" do
it "evoked Settings::SMTP.settings during callback" do
allow(Settings::SMTP).to receive(:settings)
email.deliver_now

View file

@ -1,6 +1,10 @@
require "rails_helper"
RSpec.describe Settings::SMTP do
after do
described_class.clear_cache
end
describe "::settings" do
it "use default sendgrid config if SENDGRID_API_KEY is available" do
key = "something"

View file

@ -2,6 +2,7 @@ require "rails_helper"
RSpec.describe "Authenticating with a password" do
def submit_login_form(email, password)
allow(ForemInstance).to receive(:smtp_enabled?).and_return(true)
fill_in "Email", with: email
fill_in "Password", with: password
click_button "Continue"