From ac27e86fb51bcc2d705457331fda0127397a0ae5 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sun, 6 Oct 2024 16:06:33 +0100 Subject: [PATCH] Rename /images to /covers --- .../{image_controller.ex => cover_controller.ex} | 2 +- .../controllers/stats_html/index.html.heex | 2 +- .../live/record_live/index.html.heex | 2 +- .../live/record_live/show.html.heex | 2 +- lib/music_library_web/router.ex | 2 +- ...roller_test.exs => cover_controller_test.exs} | 16 ++++++++-------- .../music_library_web/live/record_index_test.exs | 6 +++--- test/music_library_web/live/record_show_test.exs | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) rename lib/music_library_web/controllers/{image_controller.ex => cover_controller.ex} (93%) rename test/music_library_web/controllers/{image_controller_test.exs => cover_controller_test.exs} (76%) diff --git a/lib/music_library_web/controllers/image_controller.ex b/lib/music_library_web/controllers/cover_controller.ex similarity index 93% rename from lib/music_library_web/controllers/image_controller.ex rename to lib/music_library_web/controllers/cover_controller.ex index 1e642e88..8878a036 100644 --- a/lib/music_library_web/controllers/image_controller.ex +++ b/lib/music_library_web/controllers/cover_controller.ex @@ -1,4 +1,4 @@ -defmodule MusicLibraryWeb.ImageController do +defmodule MusicLibraryWeb.CoverController do use MusicLibraryWeb, :controller alias MusicLibrary.Records diff --git a/lib/music_library_web/controllers/stats_html/index.html.heex b/lib/music_library_web/controllers/stats_html/index.html.heex index 1effa597..8a9fe5e4 100644 --- a/lib/music_library_web/controllers/stats_html/index.html.heex +++ b/lib/music_library_web/controllers/stats_html/index.html.heex @@ -40,7 +40,7 @@
{@latest_record.title}

Latest record

diff --git a/lib/music_library_web/live/record_live/index.html.heex b/lib/music_library_web/live/record_live/index.html.heex index d95046eb..0690f352 100644 --- a/lib/music_library_web/live/record_live/index.html.heex +++ b/lib/music_library_web/live/record_live/index.html.heex @@ -28,7 +28,7 @@ {record.title} <%= Records.Record.format_short_label(record.format) %> diff --git a/lib/music_library_web/live/record_live/show.html.heex b/lib/music_library_web/live/record_live/show.html.heex index 09ce9b48..0ed4371c 100644 --- a/lib/music_library_web/live/record_live/show.html.heex +++ b/lib/music_library_web/live/record_live/show.html.heex @@ -15,7 +15,7 @@ {@record.title} diff --git a/lib/music_library_web/router.ex b/lib/music_library_web/router.ex index f78e41dc..2f7a6392 100644 --- a/lib/music_library_web/router.ex +++ b/lib/music_library_web/router.ex @@ -18,7 +18,7 @@ defmodule MusicLibraryWeb.Router do pipe_through :browser get "/health", HealthController, :index - get "/images/:record_id", ImageController, :show + get "/covers/:record_id", CoverController, :show get "/", StatsController, :index live "/records", RecordLive.Index, :index diff --git a/test/music_library_web/controllers/image_controller_test.exs b/test/music_library_web/controllers/cover_controller_test.exs similarity index 76% rename from test/music_library_web/controllers/image_controller_test.exs rename to test/music_library_web/controllers/cover_controller_test.exs index 48dcb1a9..44b747c8 100644 --- a/test/music_library_web/controllers/image_controller_test.exs +++ b/test/music_library_web/controllers/cover_controller_test.exs @@ -1,4 +1,4 @@ -defmodule MusicLibraryWeb.ImageControllerTest do +defmodule MusicLibraryWeb.CoverControllerTest do use MusicLibraryWeb.ConnCase import MusicLibrary.RecordsFixtures @@ -7,18 +7,18 @@ defmodule MusicLibraryWeb.ImageControllerTest do %{record: record_fixture()} end - describe "GET /images/:record_id" do + describe "GET /covers/:record_id" do setup [:create_record] test "404s when record doesn't exist", %{conn: conn} do id = Ecto.UUID.generate() - conn = get(conn, ~p"/images/#{id}") + conn = get(conn, ~p"/covers/#{id}") assert text_response(conn, 404) == "Not found" end - test "serves the image when etag doesn't exist", %{conn: conn, record: record} do - conn = get(conn, ~p"/images/#{record.id}") + test "serves the cover when etag doesn't exist", %{conn: conn, record: record} do + conn = get(conn, ~p"/covers/#{record.id}") assert conn.status == 200 assert get_resp_header(conn, "content-type") == ["image/jpeg; charset=utf-8"] @@ -27,11 +27,11 @@ defmodule MusicLibraryWeb.ImageControllerTest do assert conn.resp_body == record.cover_data end - test "serves the image when etag doesn't match", %{conn: conn, record: record} do + test "serves the cover when etag doesn't match", %{conn: conn, record: record} do conn = conn |> put_req_header("if-none-match", "invalid-etag") - |> get(~p"/images/#{record.id}") + |> get(~p"/covers/#{record.id}") assert conn.status == 200 assert get_resp_header(conn, "content-type") == ["image/jpeg; charset=utf-8"] @@ -44,7 +44,7 @@ defmodule MusicLibraryWeb.ImageControllerTest do conn = conn |> put_req_header("if-none-match", record.cover_hash) - |> get(~p"/images/#{record.id}") + |> get(~p"/covers/#{record.id}") assert conn.status == 304 assert get_resp_header(conn, "content-type") == [] diff --git a/test/music_library_web/live/record_index_test.exs b/test/music_library_web/live/record_index_test.exs index 5d9111a2..1fc610de 100644 --- a/test/music_library_web/live/record_index_test.exs +++ b/test/music_library_web/live/record_index_test.exs @@ -46,7 +46,7 @@ defmodule MusicLibraryWeb.RecordIndexTest do assert record_row_html =~ to_string(record.release) assert record_row_html =~ Record.format_short_label(record.format) assert record_row_html =~ record.release - assert record_row_html =~ ~p"/images/#{record.id}?vsn=#{record.cover_hash}" + assert record_row_html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}" for artist <- record.artists do assert record_row_html =~ escape(artist["name"]) @@ -115,7 +115,7 @@ defmodule MusicLibraryWeb.RecordIndexTest do record = record_fixture(cover_data: File.read!(marbles_cover_fixture())) {:ok, form_live, html} = live(conn, ~p"/records/#{record.id}/edit") - assert html =~ ~p"/images/#{record.id}?vsn=#{record.cover_hash}" + assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}" cover_metadata = cover_metadata(raven_cover_fixture()) @@ -135,7 +135,7 @@ defmodule MusicLibraryWeb.RecordIndexTest do assert updated_cover.cover_hash !== record.cover_hash - assert list_html =~ ~p"/images/#{record.id}?vsn=#{updated_cover.cover_hash}" + assert list_html =~ ~p"/covers/#{record.id}?vsn=#{updated_cover.cover_hash}" end defp cover_metadata(path) do diff --git a/test/music_library_web/live/record_show_test.exs b/test/music_library_web/live/record_show_test.exs index 186fe4ae..e12a5829 100644 --- a/test/music_library_web/live/record_show_test.exs +++ b/test/music_library_web/live/record_show_test.exs @@ -35,7 +35,7 @@ defmodule MusicLibraryWeb.RecordShowTest do assert html =~ to_string(record.release) assert html =~ Record.format_short_label(record.format) assert html =~ record.release - assert html =~ ~p"/images/#{record.id}?vsn=#{record.cover_hash}" + assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}" for artist <- record.artists do assert html =~ escape(artist["name"])