Revert "EmailTest: use config mock"

This reverts commit dca41cc4a3.
This commit is contained in:
Lain Soykaf 2023-12-12 19:35:19 +04:00
parent a989b793de
commit cca6c20eb6
4 changed files with 6 additions and 19 deletions

View file

@ -152,8 +152,6 @@ config :pleroma, Pleroma.Uploaders.S3, config_impl: Pleroma.UnstubbedConfigMock
config :pleroma, Pleroma.Upload, config_impl: Pleroma.UnstubbedConfigMock config :pleroma, Pleroma.Upload, config_impl: Pleroma.UnstubbedConfigMock
config :pleroma, Pleroma.ScheduledActivity, config_impl: Pleroma.UnstubbedConfigMock config :pleroma, Pleroma.ScheduledActivity, config_impl: Pleroma.UnstubbedConfigMock
config :pleroma, Pleroma.Web.RichMedia.Helpers, config_impl: Pleroma.StaticStubbedConfigMock config :pleroma, Pleroma.Web.RichMedia.Helpers, config_impl: Pleroma.StaticStubbedConfigMock
config :pleroma, Pleroma.Emails.Mailer, config_impl: Pleroma.UnstubbedConfigMock
config :pleroma, Pleroma.User, config_impl: Pleroma.UnstubbedConfigMock
if File.exists?("./config/test.secret.exs") do if File.exists?("./config/test.secret.exs") do
import_config "test.secret.exs" import_config "test.secret.exs"

View file

@ -14,10 +14,9 @@ defmodule Pleroma.Emails.Mailer do
@otp_app :pleroma @otp_app :pleroma
@mailer_config [otp: :pleroma] @mailer_config [otp: :pleroma]
@config_impl Application.compile_env(:pleroma, [__MODULE__, :config_impl], Pleroma.Config)
@spec enabled?() :: boolean() @spec enabled?() :: boolean()
def enabled?, do: @config_impl.get([__MODULE__, :enabled]) def enabled?, do: Pleroma.Config.get([__MODULE__, :enabled])
@doc "add email to queue" @doc "add email to queue"
def deliver_async(email, config \\ []) do def deliver_async(email, config \\ []) do

View file

@ -86,7 +86,6 @@ defmodule Pleroma.User do
] ]
@cachex Pleroma.Config.get([:cachex, :provider], Cachex) @cachex Pleroma.Config.get([:cachex, :provider], Cachex)
@config_impl Application.compile_env(:pleroma, [__MODULE__, :config_impl], Pleroma.Config)
schema "users" do schema "users" do
field(:bio, :string, default: "") field(:bio, :string, default: "")
@ -1001,7 +1000,7 @@ defmodule Pleroma.User do
@spec maybe_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop} @spec maybe_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop}
def maybe_send_confirmation_email(%User{is_confirmed: false, email: email} = user) def maybe_send_confirmation_email(%User{is_confirmed: false, email: email} = user)
when is_binary(email) do when is_binary(email) do
if @config_impl.get([:instance, :account_activation_required]) do if Config.get([:instance, :account_activation_required]) do
send_confirmation_email(user) send_confirmation_email(user)
{:ok, :enqueued} {:ok, :enqueued}
else else

View file

@ -3,15 +3,13 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.EmailTest do defmodule Mix.Tasks.Pleroma.EmailTest do
use Pleroma.DataCase, async: true use Pleroma.DataCase
import Swoosh.TestAssertions import Swoosh.TestAssertions
alias Pleroma.Test.StaticConfig, as: Config alias Pleroma.Config
alias Pleroma.Tests.ObanHelpers alias Pleroma.Tests.ObanHelpers
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
import Mox
import Pleroma.Factory import Pleroma.Factory
setup_all do setup_all do
@ -24,15 +22,8 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
:ok :ok
end end
setup do setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
ConfigMock setup do: clear_config([:instance, :account_activation_required], true)
|> stub(:get, fn
[Pleroma.Emails.Mailer, :enabled] -> true
[:instance, :account_activation_required] -> true
end)
:ok
end
describe "pleroma.email test" do describe "pleroma.email test" do
test "Sends test email with no given address" do test "Sends test email with no given address" do