* feat: create a from_email_address and a reply_to_email_address * feat: update other mailers with the new SMTP email settings * test: update all spec files * fix: use the SMTP::Settings value * fix tests * spec: fix the comma * feat: tighten some logic * fix: test * fix tests * fix tests * final fix test commit * fix test * fix test * oops * feat: add a reply_to for Devise Mailer * chore: update the description * use a proc for reply_to * feat: update text * Update spec/mailers/digest_mailer_spec.rb Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> * Update spec/mailers/verification_mailer_spec.rb Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> * Update spec/mailers/shared_examples/renders_proper_email_headers.rb Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> * refactor: move OPTIONS to a helper as its only being used in the view layer Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
71 lines
2.7 KiB
Ruby
71 lines
2.7 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Settings::SMTP do
|
|
let(:key) { "something" }
|
|
|
|
before { ENV["SENDGRID_API_KEY"] = key }
|
|
|
|
after do
|
|
described_class.clear_cache
|
|
ENV["SENDGRID_API_KEY"] = nil
|
|
end
|
|
|
|
describe "::settings" do
|
|
it "use falback sendgrid settings if address is not provided" do
|
|
domain = "test.com"
|
|
allow(Settings::General).to receive(:app_domain).and_return(domain)
|
|
|
|
expect(described_class.settings).to eq({
|
|
address: "smtp.sendgrid.net",
|
|
port: 587,
|
|
authentication: :plain,
|
|
user_name: "apikey",
|
|
password: key,
|
|
domain: domain
|
|
})
|
|
end
|
|
|
|
# rubocop:disable RSpec/ExampleLength
|
|
it "uses Settings::SMTP config if address is provided" do
|
|
from_email_address = "hello@forem.com"
|
|
reply_to_email_address = "reply@forem.com"
|
|
|
|
described_class.address = "smtp.google.com"
|
|
described_class.port = 25
|
|
described_class.authentication = "plain"
|
|
described_class.user_name = "username"
|
|
described_class.password = "password"
|
|
described_class.domain = "forem.local"
|
|
described_class.reply_to_email_address = reply_to_email_address
|
|
described_class.from_email_address = from_email_address
|
|
|
|
expect(described_class.settings).to eq({
|
|
address: "smtp.google.com",
|
|
port: 25,
|
|
authentication: "plain",
|
|
user_name: "username",
|
|
password: "password",
|
|
domain: "forem.local",
|
|
reply_to_email_address: reply_to_email_address,
|
|
from_email_address: from_email_address
|
|
})
|
|
end
|
|
end
|
|
# rubocop:enable RSpec/ExampleLength
|
|
|
|
describe "::provided_minimum_settings?" do
|
|
it "returns true if addess, user_name, and password are provided" do
|
|
described_class.address = "smtp.google.com"
|
|
described_class.user_name = "username"
|
|
described_class.password = "password"
|
|
|
|
expect(described_class.provided_minimum_settings?).to be true
|
|
end
|
|
|
|
it "returns false if one of addess, user_name, or password is missing" do
|
|
described_class.address = "smtp.google.com"
|
|
|
|
expect(described_class.provided_minimum_settings?).to be false
|
|
end
|
|
end
|
|
end
|