Show country flag for artist
This commit is contained in:
@@ -13,7 +13,13 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
|
||||
|
||||
[artist] = collection_record.artists
|
||||
|
||||
%{collection_record: collection_record, artist_musicbrainz_id: artist.musicbrainz_id}
|
||||
artist_info = artist_info(artist.musicbrainz_id)
|
||||
|
||||
%{
|
||||
collection_record: collection_record,
|
||||
artist_musicbrainz_id: artist.musicbrainz_id,
|
||||
artist_info: artist_info
|
||||
}
|
||||
end
|
||||
|
||||
describe "Show artist" do
|
||||
@@ -64,6 +70,27 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
|
||||
|> assert_has("div", text: "Error loading biography")
|
||||
end
|
||||
|
||||
test "it shows the artist country", %{
|
||||
conn: conn,
|
||||
artist_musicbrainz_id: artist_musicbrainz_id
|
||||
} do
|
||||
Req.Test.stub(LastFm.API, fn conn ->
|
||||
case Map.get(conn.params, "method") do
|
||||
"artist.getInfo" ->
|
||||
Req.Test.json(conn, Fixtures.Artist.get_info())
|
||||
|
||||
"artist.getSimilar" ->
|
||||
Req.Test.json(conn, Fixtures.Artist.get_similar_artists())
|
||||
end
|
||||
end)
|
||||
|
||||
conn
|
||||
|> visit(~p"/artists/#{artist_musicbrainz_id}")
|
||||
|> unwrap(&render_async/1)
|
||||
|> assert_has("span", text: "United Kingdom")
|
||||
|> assert_has("span", text: "🇬🇧")
|
||||
end
|
||||
|
||||
test "it shows records from the collection and the wishlist", %{
|
||||
conn: conn,
|
||||
collection_record: collection_record,
|
||||
|
||||
@@ -6,4 +6,11 @@ defmodule Discogs.Fixtures.Artist do
|
||||
|> File.read!()
|
||||
|> JSON.decode!()
|
||||
end
|
||||
|
||||
def image_data do
|
||||
Path.join([@fixtures_folder, "steven wilson.jpeg"])
|
||||
|> File.read!()
|
||||
end
|
||||
|
||||
def image_width, do: 225
|
||||
end
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
@@ -75,6 +75,21 @@ defmodule MusicLibrary.Fixtures.Records do
|
||||
record
|
||||
end
|
||||
|
||||
def artist_info(musicbrainz_id, attrs \\ %{}) do
|
||||
{:ok, artist_info} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
id: musicbrainz_id,
|
||||
musicbrainz_data: MusicBrainz.Fixtures.Artist.get_artist(),
|
||||
discogs_data: Discogs.Fixtures.Artist.get_artist(),
|
||||
image_data: Discogs.Fixtures.Artist.image_data(),
|
||||
image_width: Discogs.Fixtures.Artist.image_width()
|
||||
})
|
||||
|> MusicLibrary.Artists.create_artist_info()
|
||||
|
||||
artist_info
|
||||
end
|
||||
|
||||
def record_with_artist(artist_name, record_attrs \\ %{}) do
|
||||
record_attrs
|
||||
|> Map.put(:artists, [artist_attrs(artist_name)])
|
||||
|
||||
Reference in New Issue
Block a user