Use aliases

This commit is contained in:
Claudio Ortolina
2025-02-20 15:19:06 +00:00
parent 26297a8bb1
commit b2daa561d7
4 changed files with 19 additions and 15 deletions
@@ -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}
>
<option :if={@prompt} value="">{@prompt}</option>
{Phoenix.HTML.Form.options_for_select(@options, @value)}
{Form.options_for_select(@options, @value)}
</select>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
@@ -373,7 +374,7 @@ defmodule MusicLibraryWeb.CoreComponents do
@errors != [] && "border-rose-400 focus:border-rose-400"
]}
{@rest}
><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea>
><%= Form.normalize_value("textarea", @value) %></textarea>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
@@ -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",
+7 -7
View File
@@ -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 <b>%{visible}</b> of <b>%{total}</b> 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 ""
+3 -2
View File
@@ -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
+4 -2
View File
@@ -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 """