From b2daa561d71684b688a6d6671bb198cbb4702d5d Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Thu, 20 Feb 2025 15:19:06 +0000 Subject: [PATCH] Use aliases --- .../components/core_components.ex | 9 +++++---- priv/gettext/default.pot | 14 +++++++------- test/music_library/records/cover_test.exs | 5 +++-- test/support/data_case.ex | 6 ++++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/music_library_web/components/core_components.ex b/lib/music_library_web/components/core_components.ex index aa222e7f..fad36ee6 100644 --- a/lib/music_library_web/components/core_components.ex +++ b/lib/music_library_web/components/core_components.ex @@ -16,6 +16,7 @@ defmodule MusicLibraryWeb.CoreComponents do """ use Phoenix.Component + alias Phoenix.HTML.Form alias Phoenix.LiveView.JS use Gettext, backend: MusicLibraryWeb.Gettext @@ -308,7 +309,7 @@ defmodule MusicLibraryWeb.CoreComponents do def input(%{type: "checkbox"} = assigns) do assigns = assign_new(assigns, :checked, fn -> - Phoenix.HTML.Form.normalize_value("checkbox", assigns[:value]) + Form.normalize_value("checkbox", assigns[:value]) end) ~H""" @@ -353,7 +354,7 @@ defmodule MusicLibraryWeb.CoreComponents do {@rest} > - {Phoenix.HTML.Form.options_for_select(@options, @value)} + {Form.options_for_select(@options, @value)} <.error :for={msg <- @errors}>{msg} @@ -373,7 +374,7 @@ defmodule MusicLibraryWeb.CoreComponents do @errors != [] && "border-rose-400 focus:border-rose-400" ]} {@rest} - ><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %> + ><%= Form.normalize_value("textarea", @value) %> <.error :for={msg <- @errors}>{msg} """ @@ -388,7 +389,7 @@ defmodule MusicLibraryWeb.CoreComponents do type={@type} name={@name} id={@id} - value={Phoenix.HTML.Form.normalize_value(@type, @value)} + value={Form.normalize_value(@type, @value)} class={[ "mt-2 block w-full rounded-md", "border-0 border-zinc-300", diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index f1626113..f90cdae2 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -11,7 +11,7 @@ msgid "" msgstr "" -#: lib/music_library_web/components/core_components.ex:506 +#: lib/music_library_web/components/core_components.ex:507 #, elixir-autogen, elixir-format msgid "Actions" msgstr "" @@ -69,7 +69,7 @@ msgstr "" msgid "Error importing record" msgstr "" -#: lib/music_library_web/components/core_components.ex:161 +#: lib/music_library_web/components/core_components.ex:162 #, elixir-autogen, elixir-format msgid "Error!" msgstr "" @@ -90,7 +90,7 @@ msgstr "" msgid "Genres" msgstr "" -#: lib/music_library_web/components/core_components.ex:170 +#: lib/music_library_web/components/core_components.ex:171 #, elixir-autogen, elixir-format msgid "Hang in there while we get back on track" msgstr "" @@ -241,7 +241,7 @@ msgstr "" msgid "Showing %{visible} of %{total} records" msgstr "" -#: lib/music_library_web/components/core_components.ex:165 +#: lib/music_library_web/components/core_components.ex:166 #, elixir-autogen, elixir-format msgid "Something went wrong!" msgstr "" @@ -252,7 +252,7 @@ msgstr "" msgid "Stats" msgstr "" -#: lib/music_library_web/components/core_components.ex:160 +#: lib/music_library_web/components/core_components.ex:161 #, elixir-autogen, elixir-format msgid "Success!" msgstr "" @@ -314,8 +314,8 @@ msgstr "" msgid "You must be logged in to access this page" msgstr "" -#: lib/music_library_web/components/core_components.ex:81 -#: lib/music_library_web/components/core_components.ex:137 +#: lib/music_library_web/components/core_components.ex:82 +#: lib/music_library_web/components/core_components.ex:138 #, elixir-autogen, elixir-format msgid "close" msgstr "" diff --git a/test/music_library/records/cover_test.exs b/test/music_library/records/cover_test.exs index f7749059..68bc4150 100644 --- a/test/music_library/records/cover_test.exs +++ b/test/music_library/records/cover_test.exs @@ -2,13 +2,14 @@ defmodule MusicLibrary.Records.CoverTest do use ExUnit.Case, async: true import MusicLibrary.Fixtures.Records + alias MusicLibrary.Records.Cover describe "resize/1" do test "it resizes to the desired size" do cover_data = File.read!(marbles_cover_fixture()) - {:ok, resized_cover} = MusicLibrary.Records.Cover.resize(cover_data) + {:ok, resized_cover} = Cover.resize(cover_data) assert cover_data !== resized_cover - assert MusicLibrary.Records.Cover.correct_size?(resized_cover) + assert Cover.correct_size?(resized_cover) end end end diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 01a2fc26..76a99297 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -16,6 +16,8 @@ defmodule MusicLibrary.DataCase do use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox + using do quote do alias MusicLibrary.Repo @@ -36,8 +38,8 @@ defmodule MusicLibrary.DataCase do Sets up the sandbox based on the test tags. """ def setup_sandbox(tags) do - pid = Ecto.Adapters.SQL.Sandbox.start_owner!(MusicLibrary.Repo, shared: not tags[:async]) - on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) + pid = Sandbox.start_owner!(MusicLibrary.Repo, shared: not tags[:async]) + on_exit(fn -> Sandbox.stop_owner(pid) end) end @doc """