mirror of
https://github.com/plausible/analytics.git
synced 2024-12-22 17:11:36 +03:00
add MAILER_NAME (#2937)
* add MAILER_NAME * add mailer test --------- Co-authored-by: Uku Taht <Uku.taht@gmail.com>
This commit is contained in:
parent
e4b1aa64d1
commit
ce7401dd83
@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
||||
- 'Last updated X seconds ago' info to 'current visitors' tooltips
|
||||
- Add support for more Bamboo adapters, i.e. `Bamboo.MailgunAdapter`, `Bamboo.MandrillAdapter`, `Bamboo.SendGridAdapter` plausible/analytics#2649
|
||||
- Ability to change domain for existing site (requires numeric IDs data migration, instructions will be provided separately) UI + API (`PUT /api/v1/sites`)
|
||||
- Add `MAILER_NAME` environment variable support plausible/analytics#2937
|
||||
- Add `MAILGUN_BASE_URI` support for `Bamboo.MailgunAdapter` plausible/analytics#2935
|
||||
|
||||
### Fixed
|
||||
|
@ -72,6 +72,14 @@ super_admin_user_ids =
|
||||
env = get_var_from_path_or_env(config_dir, "ENVIRONMENT", "prod")
|
||||
mailer_adapter = get_var_from_path_or_env(config_dir, "MAILER_ADAPTER", "Bamboo.SMTPAdapter")
|
||||
mailer_email = get_var_from_path_or_env(config_dir, "MAILER_EMAIL", "hello@plausible.local")
|
||||
|
||||
mailer_email =
|
||||
if mailer_name = get_var_from_path_or_env(config_dir, "MAILER_NAME") do
|
||||
{mailer_name, mailer_email}
|
||||
else
|
||||
mailer_email
|
||||
end
|
||||
|
||||
app_version = get_var_from_path_or_env(config_dir, "APP_VERSION", "0.0.1")
|
||||
|
||||
ch_db_url =
|
||||
|
@ -2,6 +2,28 @@ defmodule Plausible.ConfigTest do
|
||||
use ExUnit.Case
|
||||
|
||||
describe "mailer" do
|
||||
test "mailer email default" do
|
||||
env = [{"MAILER_EMAIL", nil}]
|
||||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == "hello@plausible.local"
|
||||
end
|
||||
|
||||
test "mailer email custom" do
|
||||
env = [{"MAILER_EMAIL", "custom@mailer.email"}]
|
||||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) == "custom@mailer.email"
|
||||
end
|
||||
|
||||
test "mailer name" do
|
||||
env = [{"MAILER_EMAIL", nil}, {"MAILER_NAME", "John"}]
|
||||
|
||||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) ==
|
||||
{"John", "hello@plausible.local"}
|
||||
|
||||
env = [{"MAILER_EMAIL", "custom@mailer.email"}, {"MAILER_NAME", "John"}]
|
||||
|
||||
assert get_in(runtime_config(env), [:plausible, :mailer_email]) ==
|
||||
{"John", "custom@mailer.email"}
|
||||
end
|
||||
|
||||
test "defaults to Bamboo.SMTPAdapter" do
|
||||
env = {"MAILER_ADAPTER", nil}
|
||||
|
||||
|
33
test/plausible/mailer_test.exs
Normal file
33
test/plausible/mailer_test.exs
Normal file
@ -0,0 +1,33 @@
|
||||
defmodule Plausible.MailerTest do
|
||||
use Plausible.DataCase
|
||||
use Bamboo.Test
|
||||
|
||||
describe "from" do
|
||||
setup do
|
||||
{:ok, user: insert(:user)}
|
||||
end
|
||||
|
||||
# see config tests as well
|
||||
test "when MAILER_NAME and MAILER_EMAIL", %{user: user} do
|
||||
mailer_email = {"John", "custom@mailer.email"}
|
||||
patch_env(:mailer_email, mailer_email)
|
||||
|
||||
email = PlausibleWeb.Email.welcome_email(user)
|
||||
assert :ok = Plausible.Mailer.send(email)
|
||||
|
||||
assert_delivered_email(email)
|
||||
assert email.from == mailer_email
|
||||
end
|
||||
|
||||
test "when MAILER_EMAIL", %{user: user} do
|
||||
mailer_email = "custom@mailer.email"
|
||||
patch_env(:mailer_email, mailer_email)
|
||||
|
||||
email = PlausibleWeb.Email.welcome_email(user)
|
||||
assert :ok = Plausible.Mailer.send(email)
|
||||
|
||||
assert_delivered_email(email)
|
||||
assert email.from == mailer_email
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user