fix module aliasing issues
This commit is contained in:
parent
0a7ad6af8a
commit
11396e37a8
1
.gitignore
vendored
1
.gitignore
vendored
@ -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/
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -51,7 +51,12 @@
|
||||
<h2 class="text-2xl font-display font-semibold">QWAN</h2>
|
||||
<div class="space-y-4 text-lg leading-relaxed text-base-content/80">
|
||||
<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,
|
||||
or just want to nerd out about agentic systems, feel free to reach out.
|
||||
</p>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
rel="noopener"
|
||||
>QWAN</a>.
|
||||
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>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user