2024-03-13 22:55:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe ProblemCheck::MissingMailgunApiKey do
|
|
|
|
subject(:check) { described_class.new }
|
|
|
|
|
|
|
|
describe ".call" do
|
|
|
|
before do
|
|
|
|
SiteSetting.stubs(reply_by_email_enabled: replies_enabled)
|
2024-03-17 19:10:30 -04:00
|
|
|
ActionMailer::Base.stubs(smtp_settings: { address: mailgun_address })
|
2024-03-13 22:55:01 -04:00
|
|
|
SiteSetting.stubs(mailgun_api_key: api_key)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when replies are disabled" do
|
|
|
|
let(:replies_enabled) { false }
|
|
|
|
let(:mailgun_address) { anything }
|
|
|
|
let(:api_key) { anything }
|
|
|
|
|
|
|
|
it { expect(check).to be_chill_about_it }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when not using Mailgun for replies" do
|
|
|
|
let(:replies_enabled) { false }
|
|
|
|
let(:mailgun_address) { nil }
|
|
|
|
let(:api_key) { anything }
|
|
|
|
|
|
|
|
it { expect(check).to be_chill_about_it }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when using Mailgun without an API key" do
|
|
|
|
let(:replies_enabled) { true }
|
2024-03-17 19:10:30 -04:00
|
|
|
let(:mailgun_address) { "smtp.mailgun.org" }
|
2024-03-13 22:55:01 -04:00
|
|
|
let(:api_key) { nil }
|
|
|
|
|
|
|
|
it do
|
|
|
|
expect(check).to have_a_problem.with_priority("low").with_message(
|
|
|
|
"The server is configured to send emails via Mailgun but you haven't provided an API key used to verify the webhook messages.",
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|