fix module aliasing issues

This commit is contained in:
Willem van den Ende 2026-05-05 23:04:01 +01:00
parent 0a7ad6af8a
commit 11396e37a8
11 changed files with 43 additions and 22 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ dokku-setup.sh
app/priv/blog/engineering/2026/04-24-what-it-takes-to-get-started-with-the-pi-coding-agent.md app/priv/blog/engineering/2026/04-24-what-it-takes-to-get-started-with-the-pi-coding-agent.md
/tmp_work/ /tmp_work/
.yaks .yaks
transcripts/

View File

@ -6,7 +6,7 @@ defmodule Firehose.Accounts do
import Ecto.Query, warn: false import Ecto.Query, warn: false
alias Firehose.Repo alias Firehose.Repo
alias Firehose.Accounts.{User, UserToken, UserNotifier} alias Firehose.Accounts.{User, UserNotifier, UserToken}
## Database getters ## Database getters

View File

@ -8,8 +8,8 @@ defmodule Firehose.Accounts.UserNotifier do
import Swoosh.Email import Swoosh.Email
alias Firehose.Mailer
alias Firehose.Accounts.User alias Firehose.Accounts.User
alias Firehose.Mailer
# Delivers the email using the application mailer. # Delivers the email using the application mailer.
defp deliver(recipient, subject, body) do defp deliver(recipient, subject, body) do

View File

@ -51,7 +51,12 @@
<h2 class="text-2xl font-display font-semibold">QWAN</h2> <h2 class="text-2xl font-display font-semibold">QWAN</h2>
<div class="space-y-4 text-lg leading-relaxed text-base-content/80"> <div class="space-y-4 text-lg leading-relaxed text-base-content/80">
<p> <p>
I'm a partner at <a href="https://qwan.eu" class="text-primary hover:underline" target="_blank" rel="noopener">QWAN</a>, I'm a partner at <a
href="https://qwan.eu"
class="text-primary hover:underline"
target="_blank"
rel="noopener"
>QWAN</a>,
where we build software based on user needs, and help others do the same, and learn together. If you're looking for collaboration, have a product you want to build, a service that needs improvement, where we build software based on user needs, and help others do the same, and learn together. If you're looking for collaboration, have a product you want to build, a service that needs improvement,
or just want to nerd out about agentic systems, feel free to reach out. or just want to nerd out about agentic systems, feel free to reach out.
</p> </p>

View File

@ -13,7 +13,7 @@
rel="noopener" rel="noopener"
>QWAN</a>. >QWAN</a>.
This is where I write about agentic engineering, wishcraft, naive evals, This is where I write about agentic engineering, wishcraft, naive evals,
and whatever prototype I'm building this week. and whatever prototype I'm building this week.
</p> </p>
</div> </div>
</section> </section>

View File

@ -251,14 +251,16 @@ defmodule FirehoseWeb.UserAuth do
defp mount_current_scope(socket, session) do defp mount_current_scope(socket, session) do
Phoenix.Component.assign_new(socket, :current_scope, fn -> Phoenix.Component.assign_new(socket, :current_scope, fn ->
if token = session["user_token"] do scope_from_session(session)
case Accounts.get_user_by_session_token(token) do
{user, _token_inserted_at} -> Scope.for_user(user)
nil -> Scope.for_user(nil)
end
else
Scope.for_user(nil)
end
end) end)
end end
defp scope_from_session(%{"user_token" => token}) do
case Accounts.get_user_by_session_token(token) do
{user, _token_inserted_at} -> Scope.for_user(user)
nil -> Scope.for_user(nil)
end
end
defp scope_from_session(_session), do: Scope.for_user(nil)
end end

View File

@ -10,7 +10,8 @@ defmodule FirehoseWeb.BlogControllerTest do
describe "GET /blog/:blog_id/:slug (show) - date filtering" do describe "GET /blog/:blog_id/:slug (show) - date filtering" do
test "still shows a future-dated post by slug", %{conn: conn} do test "still shows a future-dated post by slug", %{conn: conn} do
assert conn |> get(~p"/blog/engineering/future-test-post") |> html_response(200) =~ "Future Test Post" assert conn |> get(~p"/blog/engineering/future-test-post") |> html_response(200) =~
"Future Test Post"
end end
end end

View File

@ -59,7 +59,9 @@ defmodule FirehoseWeb.UserRegistrationControllerTest do
Application.put_env(:firehose, :allowed_registration_email, "allowed@example.com") Application.put_env(:firehose, :allowed_registration_email, "allowed@example.com")
on_exit(fn -> Application.delete_env(:firehose, :allowed_registration_email) end) on_exit(fn -> Application.delete_env(:firehose, :allowed_registration_email) end)
response = conn |> post(~p"/users/register", %{"user" => %{"email" => "allowed@example.com"}}) response =
conn |> post(~p"/users/register", %{"user" => %{"email" => "allowed@example.com"}})
assert Phoenix.Flash.get(response.assigns.flash, :info) =~ "email was sent" assert Phoenix.Flash.get(response.assigns.flash, :info) =~ "email was sent"
end end
@ -67,13 +69,17 @@ defmodule FirehoseWeb.UserRegistrationControllerTest do
Application.put_env(:firehose, :allowed_registration_email, "allowed@example.com") Application.put_env(:firehose, :allowed_registration_email, "allowed@example.com")
on_exit(fn -> Application.delete_env(:firehose, :allowed_registration_email) end) on_exit(fn -> Application.delete_env(:firehose, :allowed_registration_email) end)
assert conn |> post(~p"/users/register", %{"user" => %{"email" => "other@example.com"}}) |> html_response(200) =~ "registration is invite only" assert conn
|> post(~p"/users/register", %{"user" => %{"email" => "other@example.com"}})
|> html_response(200) =~ "registration is invite only"
end end
test "fails with invite-only message when env var is unset", %{conn: conn} do test "fails with invite-only message when env var is unset", %{conn: conn} do
Application.delete_env(:firehose, :allowed_registration_email) Application.delete_env(:firehose, :allowed_registration_email)
assert conn |> post(~p"/users/register", %{"user" => %{"email" => "anyone@example.com"}}) |> html_response(200) =~ "registration is invite only" assert conn
|> post(~p"/users/register", %{"user" => %{"email" => "anyone@example.com"}})
|> html_response(200) =~ "registration is invite only"
end end
end end
end end

View File

@ -46,7 +46,8 @@ defmodule FirehoseWeb.UserSessionControllerTest do
Accounts.deliver_login_instructions(user, url) Accounts.deliver_login_instructions(user, url)
end) end)
assert conn |> get(~p"/users/log-in/#{token}") |> html_response(200) =~ "Confirm and stay logged in" assert conn |> get(~p"/users/log-in/#{token}") |> html_response(200) =~
"Confirm and stay logged in"
end end
test "renders login page for confirmed user", %{conn: conn, user: user} do test "renders login page for confirmed user", %{conn: conn, user: user} do

View File

@ -1,3 +1,5 @@
alias Firehose.Test.FakeBlog
defmodule FirehoseWeb.EditorDashboardLiveTest do defmodule FirehoseWeb.EditorDashboardLiveTest do
use FirehoseWeb.ConnCase, async: true use FirehoseWeb.ConnCase, async: true
@ -41,13 +43,13 @@ defmodule FirehoseWeb.EditorDashboardLiveTest do
] ]
{:ok, _} = {:ok, _} =
Firehose.Test.FakeBlog.start(posts, FakeBlog.start(posts,
blog_id: :test_blog, blog_id: :test_blog,
title: "Test Blog", title: "Test Blog",
base_path: "/blog/test" base_path: "/blog/test"
) )
Application.put_env(:blogex, :blogs, [Firehose.Test.FakeBlog]) Application.put_env(:blogex, :blogs, [FakeBlog])
on_exit(fn -> Application.delete_env(:blogex, :blogs) end) on_exit(fn -> Application.delete_env(:blogex, :blogs) end)
:ok :ok

View File

@ -15,6 +15,9 @@ defmodule FirehoseWeb.ConnCase do
this option is not recommended for other databases. this option is not recommended for other databases.
""" """
alias Firehose.Accounts.Scope
alias Firehose.AccountsFixtures
use ExUnit.CaseTemplate use ExUnit.CaseTemplate
using do using do
@ -45,8 +48,8 @@ defmodule FirehoseWeb.ConnCase do
test context. test context.
""" """
def register_and_log_in_user(%{conn: conn} = context) do def register_and_log_in_user(%{conn: conn} = context) do
user = Firehose.AccountsFixtures.user_fixture() user = AccountsFixtures.user_fixture()
scope = Firehose.Accounts.Scope.for_user(user) scope = Scope.for_user(user)
opts = opts =
context context
@ -74,6 +77,6 @@ defmodule FirehoseWeb.ConnCase do
defp maybe_set_token_authenticated_at(_token, nil), do: nil defp maybe_set_token_authenticated_at(_token, nil), do: nil
defp maybe_set_token_authenticated_at(token, authenticated_at) do defp maybe_set_token_authenticated_at(token, authenticated_at) do
Firehose.AccountsFixtures.override_token_authenticated_at(token, authenticated_at) AccountsFixtures.override_token_authenticated_at(token, authenticated_at)
end end
end end