Rename record.release to record.release_date

Includes changes to dependent tables (i.e. the record search index) and
related functions.
This commit is contained in:
Claudio Ortolina
2025-05-01 14:04:57 +01:00
parent 8be0144cc7
commit e083950138
20 changed files with 1066 additions and 51 deletions
@@ -9,7 +9,7 @@ defmodule MusicLibrary.BarcodeScan.ResultTest do
type: :album,
title: "Test Release Group",
artists: ["Test Artist"],
release: "2021-01-01"
release_date: "2021-01-01"
}
@release %ReleaseSearchResult{
+8 -8
View File
@@ -16,26 +16,26 @@ defmodule MusicLibrary.Records.RecordTest do
test "returns true if the record has a release date in the past", %{
current_date: current_date
} do
record = %Record{release: "2024-01-01"}
record = %Record{release_date: "2024-01-01"}
assert Record.released?(record, current_date)
end
test "returns false if the record has a release date in the future", %{
current_date: current_date
} do
record = %Record{release: "2025-02-01"}
record = %Record{release_date: "2025-02-01"}
refute Record.released?(record, current_date)
end
test "returns true if the record is released today", %{current_date: current_date} do
record = %Record{release: "2025-01-01"}
record = %Record{release_date: "2025-01-01"}
assert Record.released?(record, current_date)
end
test "it returns true if the release date is not precise enough", %{
current_date: current_date
} do
record = %Record{release: "2019"}
record = %Record{release_date: "2019"}
assert Record.released?(record, current_date)
end
end
@@ -54,28 +54,28 @@ defmodule MusicLibrary.Records.RecordTest do
id: "749c07b5-4900-404b-bea9-bb6b16fa991e",
type: :other,
title: "Claustrophobic Universe",
release: "2021-04-23",
release_date: "2021-04-23",
artists: "Mariusz Duda"
},
%MusicBrainz.ReleaseGroupSearchResult{
id: "61077431-0057-4119-8f06-0df1098d21e5",
type: :other,
title: "Interior Drawings",
release: "2021-12-10",
release_date: "2021-12-10",
artists: "Mariusz Duda"
},
%MusicBrainz.ReleaseGroupSearchResult{
id: "c36123e3-8899-48a5-8196-9dbb72421d69",
type: :other,
title: "Lets Meet Outside",
release: "2022-05-20",
release_date: "2022-05-20",
artists: "Mariusz Duda"
},
%MusicBrainz.ReleaseGroupSearchResult{
id: "d463f2b1-d254-4baf-a957-fb78c6e5b956",
type: :other,
title: "Lockdown Spaces",
release: "2020-06-26",
release_date: "2020-06-26",
artists: "Mariusz Duda"
}
]
@@ -49,7 +49,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
session
|> assert_has("#records-#{record.id}")
|> assert_has("#records-#{record.id} h2", text: escape(record.title))
|> assert_has("#records-#{record.id} p", text: record.release)
|> assert_has("#records-#{record.id} p", text: record.release_date)
|> assert_has("#records-#{record.id} p", text: format_label(record.format))
|> assert_has("#records-#{record.id} p", text: type_label(record.type))
|> assert_has("#records-#{record.id} span",
@@ -134,7 +134,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
session
|> assert_has("#records-#{record.id}")
|> assert_has("#records-#{record.id} h2", text: escape(record.title))
|> assert_has("#records-#{record.id} p", text: record.release)
|> assert_has("#records-#{record.id} p", text: record.release_date)
|> assert_has("#records-#{record.id} p", text: format_label(record.format))
|> assert_has("#records-#{record.id} p", text: type_label(record.type))
|> assert_has("#records-#{record.id} span",
@@ -176,7 +176,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
session
|> assert_has("#records-#{record.id}")
|> assert_has("#records-#{record.id} h2", text: escape(record.title))
|> assert_has("#records-#{record.id} p", text: record.release)
|> assert_has("#records-#{record.id} p", text: record.release_date)
|> assert_has("#records-#{record.id} p", text: format_label(record.format))
|> assert_has("#records-#{record.id} p", text: type_label(record.type))
|> assert_has("#records-#{record.id} span",
@@ -277,7 +277,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
session
|> assert_has("h1", text: result.artists)
|> assert_has("h2", text: result.title)
|> assert_has("p", text: Record.format_release(result.release))
|> assert_has("p", text: Record.format_release_date(result.release_date))
end
session =
@@ -288,7 +288,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
assert record.musicbrainz_id == first_release_group_search_result_id
assert record.title == "Marbles"
assert record.release == "2004-05-03"
assert record.release_date == "2004-05-03"
assert record.format == :cd
assert record.musicbrainz_data == release_group
@@ -392,7 +392,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
assert record.musicbrainz_id == release_group_id
assert record.title == "Marbles"
assert record.release == "2004-05-03"
assert record.release_date == "2004-05-03"
assert record.format == :cd
assert record.musicbrainz_data == release_group
@@ -26,7 +26,7 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
conn
|> visit(~p"/collection/#{record.id}")
|> assert_has("h2", text: escape(record.title))
|> assert_has("p", text: record.release)
|> assert_has("p", text: record.release_date)
|> assert_has("p", text: format_label(record.format))
|> assert_has("p", text: type_label(record.type))
|> assert_has("dd", text: Record.format_as_date(record.purchased_at))
@@ -26,7 +26,7 @@ defmodule MusicLibraryWeb.WishlistLive.ShowTest do
conn
|> visit(~p"/wishlist/#{record.id}")
|> assert_has("h2", text: escape(record.title))
|> assert_has("p", text: record.release)
|> assert_has("p", text: record.release_date)
|> assert_has("p", text: format_label(record.format))
|> assert_has("p", text: type_label(record.type))
|> assert_has("dd", text: record.id)
@@ -66,7 +66,7 @@ defmodule MusicLibrary.Fixtures.Records do
title: Enum.random(@titles),
type: :album,
format: Record.formats() |> Enum.random(),
release: Enum.random(1969..2024) |> Integer.to_string(),
release_date: Enum.random(1969..2024) |> Integer.to_string(),
purchased_at: current_time,
artists: [artist_attrs(artist_name)]
})