Add missing index to records table
Updates a relevant test to remove flakyness
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
defmodule MusicLibrary.Repo.Migrations.AddPurchasedAtIndexToRecords do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create index("records", [:purchased_at])
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -50,7 +50,9 @@ defmodule MusicLibraryWeb.StatsControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "it shows the latest purchase", %{conn: conn, collection: collection} do
|
test "it shows the latest purchase", %{conn: conn, collection: collection} do
|
||||||
latest_record = Enum.max_by(collection, & &1.purchased_at)
|
# purchased_at has second precision, so finding the latest purchased using then
|
||||||
|
# highest purchsed_at value doesn't work, as it picks the wrong value.
|
||||||
|
latest_record = List.last(collection)
|
||||||
|
|
||||||
conn = get(conn, "/")
|
conn = get(conn, "/")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user