fix emails
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-07-28 13:00:53 -04:00
parent 3c3391b3a6
commit eeef7c94cd
9 changed files with 54 additions and 12 deletions

View File

@ -0,0 +1,40 @@
defmodule Memex.EmailWorkerTest do
use Memex.DataCase, async: true
def perform_job(worker, args) do
Oban.Testing.perform_job(worker, args, [])
end
test "sending welcome email" do
user = user_fixture()
{:ok, _user} =
perform_job(Memex.EmailWorker, %{
"email" => "welcome",
"user_id" => user.id,
"attrs" => %{"url" => "test_url"}
})
end
test "sending reset password email" do
user = user_fixture()
{:ok, _user} =
perform_job(Memex.EmailWorker, %{
"email" => "reset_password",
"user_id" => user.id,
"attrs" => %{"url" => "test_url"}
})
end
test "sending update email email" do
user = user_fixture()
{:ok, _user} =
perform_job(Memex.EmailWorker, %{
"email" => "update_email",
"user_id" => user.id,
"attrs" => %{"url" => "test_url"}
})
end
end

View File

@ -38,8 +38,9 @@ defmodule Memex.Fixtures do
def extract_user_token(fun) do
%{args: %{attrs: attrs, email: email_key, user_id: user_id}} = fun.(&"[TOKEN]#{&1}[TOKEN]")
# convert atoms to string keys
attrs = attrs |> Map.new(fn {atom_key, value} -> {atom_key |> Atom.to_string(), value} end)
attrs =
attrs
|> Map.new(fn {key, value} -> {Atom.to_string(key), value} end)
email =
email_key