mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Set up SES mail delivery and harden the mailing list (#120)
* setup basic SES email sending * basic honeypot form form submission
This commit is contained in:
@@ -9,6 +9,8 @@ defmodule Chesstrainer.AccountsTest do
|
||||
alias Chesstrainer.Attempts
|
||||
alias Chesstrainer.Attempts.Attempt
|
||||
alias Chesstrainer.Accounts.Scope
|
||||
alias Chesstrainer.MailingList
|
||||
alias Chesstrainer.MailingList.Subscriber
|
||||
|
||||
describe "get_user_by_email/1" do
|
||||
test "does not return the user if the email does not exist" do
|
||||
@@ -340,6 +342,19 @@ defmodule Chesstrainer.AccountsTest do
|
||||
refute Repo.get_by(UserToken, user_id: user.id)
|
||||
end
|
||||
|
||||
test "updates the linked mailing-list address", %{
|
||||
user: user,
|
||||
token: token,
|
||||
email: email
|
||||
} do
|
||||
{:ok, _subscriber} = MailingList.subscribe_user(user)
|
||||
MailingList.confirm_user_subscription(user)
|
||||
|
||||
assert {:ok, %{email: ^email}} = Accounts.update_user_email(user, token)
|
||||
|
||||
assert %Subscriber{email: ^email} = Repo.get_by(Subscriber, user_id: user.id)
|
||||
end
|
||||
|
||||
test "does not update email with invalid token", %{user: user} do
|
||||
assert Accounts.update_user_email(user, "oops") ==
|
||||
{:error, :transaction_aborted}
|
||||
|
||||
Reference in New Issue
Block a user