From b7f2a026b9e0a707bd56d3ec63037e47448282cf Mon Sep 17 00:00:00 2001 From: Mat Trudel Date: Sun, 22 Jun 2025 21:43:49 -0400 Subject: [PATCH] Unallow existing allowances when attempting to allow a Plug to access a connection --- lib/phoenix_ecto/sql/sandbox.ex | 2 +- test/phoenix_ecto/sql/sandbox_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/phoenix_ecto/sql/sandbox.ex b/lib/phoenix_ecto/sql/sandbox.ex index 2c1bc34..928bda3 100644 --- a/lib/phoenix_ecto/sql/sandbox.ex +++ b/lib/phoenix_ecto/sql/sandbox.ex @@ -339,7 +339,7 @@ defmodule Phoenix.Ecto.SQL.Sandbox do end def allow(%{repo: repo, owner: owner}, sandbox), - do: Enum.each(List.wrap(repo), &sandbox.allow(&1, owner, self())) + do: Enum.each(List.wrap(repo), &sandbox.allow(&1, owner, self(), unallow_existing: true)) def allow(%{}, _sandbox), do: :ok def allow(nil, _sandbox), do: :ok diff --git a/test/phoenix_ecto/sql/sandbox_test.exs b/test/phoenix_ecto/sql/sandbox_test.exs index 3e23474..192b0a4 100644 --- a/test/phoenix_ecto/sql/sandbox_test.exs +++ b/test/phoenix_ecto/sql/sandbox_test.exs @@ -15,7 +15,7 @@ defmodule PhoenixEcto.SQL.SandboxTest do :ok end - def allow(repo, owner, _allowed) do + def allow(repo, owner, _allowed, _opts \\ []) do send(owner, {:allowed, repo}) end end