From 11396e37a859df5798a9afd6da1a2fa047104830 Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Tue, 5 May 2026 23:04:01 +0100 Subject: [PATCH] fix module aliasing issues --- .gitignore | 1 + app/lib/firehose/accounts.ex | 2 +- app/lib/firehose/accounts/user_notifier.ex | 2 +- .../controllers/page_html/contact.html.heex | 7 ++++++- .../controllers/page_html/home.html.heex | 2 +- app/lib/firehose_web/user_auth.ex | 18 ++++++++++-------- .../controllers/blog_controller_test.exs | 3 ++- .../user_registration_controller_test.exs | 12 +++++++++--- .../user_session_controller_test.exs | 3 ++- .../live/editor_dashboard_live_test.exs | 6 ++++-- app/test/support/conn_case.ex | 9 ++++++--- 11 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index d48b390..f88244f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 /tmp_work/ .yaks +transcripts/ diff --git a/app/lib/firehose/accounts.ex b/app/lib/firehose/accounts.ex index 2850e5f..c7eeded 100644 --- a/app/lib/firehose/accounts.ex +++ b/app/lib/firehose/accounts.ex @@ -6,7 +6,7 @@ defmodule Firehose.Accounts do import Ecto.Query, warn: false alias Firehose.Repo - alias Firehose.Accounts.{User, UserToken, UserNotifier} + alias Firehose.Accounts.{User, UserNotifier, UserToken} ## Database getters diff --git a/app/lib/firehose/accounts/user_notifier.ex b/app/lib/firehose/accounts/user_notifier.ex index 4cc4a7c..9cb0757 100644 --- a/app/lib/firehose/accounts/user_notifier.ex +++ b/app/lib/firehose/accounts/user_notifier.ex @@ -8,8 +8,8 @@ defmodule Firehose.Accounts.UserNotifier do import Swoosh.Email - alias Firehose.Mailer alias Firehose.Accounts.User + alias Firehose.Mailer # Delivers the email using the application mailer. defp deliver(recipient, subject, body) do diff --git a/app/lib/firehose_web/controllers/page_html/contact.html.heex b/app/lib/firehose_web/controllers/page_html/contact.html.heex index 080b112..b010d0c 100644 --- a/app/lib/firehose_web/controllers/page_html/contact.html.heex +++ b/app/lib/firehose_web/controllers/page_html/contact.html.heex @@ -51,7 +51,12 @@

QWAN

- I'm a partner at QWAN, + I'm a partner at QWAN, 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.

diff --git a/app/lib/firehose_web/controllers/page_html/home.html.heex b/app/lib/firehose_web/controllers/page_html/home.html.heex index 02ab5e8..0a9d4a9 100644 --- a/app/lib/firehose_web/controllers/page_html/home.html.heex +++ b/app/lib/firehose_web/controllers/page_html/home.html.heex @@ -13,7 +13,7 @@ rel="noopener" >QWAN. 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.

diff --git a/app/lib/firehose_web/user_auth.ex b/app/lib/firehose_web/user_auth.ex index b53f91b..230fd28 100644 --- a/app/lib/firehose_web/user_auth.ex +++ b/app/lib/firehose_web/user_auth.ex @@ -251,14 +251,16 @@ defmodule FirehoseWeb.UserAuth do defp mount_current_scope(socket, session) do Phoenix.Component.assign_new(socket, :current_scope, fn -> - if token = session["user_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 - else - Scope.for_user(nil) - end + scope_from_session(session) 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 diff --git a/app/test/firehose_web/controllers/blog_controller_test.exs b/app/test/firehose_web/controllers/blog_controller_test.exs index 5e9b06e..a449da2 100644 --- a/app/test/firehose_web/controllers/blog_controller_test.exs +++ b/app/test/firehose_web/controllers/blog_controller_test.exs @@ -10,7 +10,8 @@ defmodule FirehoseWeb.BlogControllerTest do describe "GET /blog/:blog_id/:slug (show) - date filtering" 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 diff --git a/app/test/firehose_web/controllers/user_registration_controller_test.exs b/app/test/firehose_web/controllers/user_registration_controller_test.exs index 09ef29d..468aa87 100644 --- a/app/test/firehose_web/controllers/user_registration_controller_test.exs +++ b/app/test/firehose_web/controllers/user_registration_controller_test.exs @@ -59,7 +59,9 @@ defmodule FirehoseWeb.UserRegistrationControllerTest do Application.put_env(:firehose, :allowed_registration_email, "allowed@example.com") 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" end @@ -67,13 +69,17 @@ defmodule FirehoseWeb.UserRegistrationControllerTest do Application.put_env(:firehose, :allowed_registration_email, "allowed@example.com") 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 test "fails with invite-only message when env var is unset", %{conn: conn} do 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 diff --git a/app/test/firehose_web/controllers/user_session_controller_test.exs b/app/test/firehose_web/controllers/user_session_controller_test.exs index bbad175..1a2d053 100644 --- a/app/test/firehose_web/controllers/user_session_controller_test.exs +++ b/app/test/firehose_web/controllers/user_session_controller_test.exs @@ -46,7 +46,8 @@ defmodule FirehoseWeb.UserSessionControllerTest do Accounts.deliver_login_instructions(user, url) 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 test "renders login page for confirmed user", %{conn: conn, user: user} do diff --git a/app/test/firehose_web/live/editor_dashboard_live_test.exs b/app/test/firehose_web/live/editor_dashboard_live_test.exs index 462dd9b..40c22de 100644 --- a/app/test/firehose_web/live/editor_dashboard_live_test.exs +++ b/app/test/firehose_web/live/editor_dashboard_live_test.exs @@ -1,3 +1,5 @@ +alias Firehose.Test.FakeBlog + defmodule FirehoseWeb.EditorDashboardLiveTest do use FirehoseWeb.ConnCase, async: true @@ -41,13 +43,13 @@ defmodule FirehoseWeb.EditorDashboardLiveTest do ] {:ok, _} = - Firehose.Test.FakeBlog.start(posts, + FakeBlog.start(posts, blog_id: :test_blog, title: "Test Blog", 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) :ok diff --git a/app/test/support/conn_case.ex b/app/test/support/conn_case.ex index 4616a64..cc01502 100644 --- a/app/test/support/conn_case.ex +++ b/app/test/support/conn_case.ex @@ -15,6 +15,9 @@ defmodule FirehoseWeb.ConnCase do this option is not recommended for other databases. """ + alias Firehose.Accounts.Scope + alias Firehose.AccountsFixtures + use ExUnit.CaseTemplate using do @@ -45,8 +48,8 @@ defmodule FirehoseWeb.ConnCase do test context. """ def register_and_log_in_user(%{conn: conn} = context) do - user = Firehose.AccountsFixtures.user_fixture() - scope = Firehose.Accounts.Scope.for_user(user) + user = AccountsFixtures.user_fixture() + scope = Scope.for_user(user) opts = 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, authenticated_at) do - Firehose.AccountsFixtures.override_token_authenticated_at(token, authenticated_at) + AccountsFixtures.override_token_authenticated_at(token, authenticated_at) end end