add tests for email verification flag lifecycle
All checks were successful
deploy / deploy (push) Successful in 34s
All checks were successful
deploy / deploy (push) Successful in 34s
Tests that sending a test email sets the verified flag, saving config clears it, and disconnecting clears it. Also adds unit tests for email_verified?/mark/clear in the Mailer module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,35 @@ defmodule Berrypod.MailerTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "email_verified?/0" do
|
||||
test "returns false when adapter is Local" do
|
||||
Application.put_env(:berrypod, Mailer, adapter: Swoosh.Adapters.Local)
|
||||
Mailer.mark_email_verified()
|
||||
refute Mailer.email_verified?()
|
||||
end
|
||||
|
||||
test "returns false when configured but not verified" do
|
||||
Application.put_env(:berrypod, Mailer, adapter: Swoosh.Adapters.Postmark, api_key: "test")
|
||||
Mailer.clear_email_verified()
|
||||
refute Mailer.email_verified?()
|
||||
end
|
||||
|
||||
test "returns true when configured and verified" do
|
||||
Application.put_env(:berrypod, Mailer, adapter: Swoosh.Adapters.Postmark, api_key: "test")
|
||||
Mailer.mark_email_verified()
|
||||
assert Mailer.email_verified?()
|
||||
end
|
||||
|
||||
test "clear_email_verified resets the flag" do
|
||||
Application.put_env(:berrypod, Mailer, adapter: Swoosh.Adapters.Postmark, api_key: "test")
|
||||
Mailer.mark_email_verified()
|
||||
assert Mailer.email_verified?()
|
||||
|
||||
Mailer.clear_email_verified()
|
||||
refute Mailer.email_verified?()
|
||||
end
|
||||
end
|
||||
|
||||
describe "current_config/0" do
|
||||
test "returns {nil, %{}} when no adapter configured" do
|
||||
Application.put_env(:berrypod, Mailer, adapter: Swoosh.Adapters.Local)
|
||||
|
||||
Reference in New Issue
Block a user