diff --git a/lib/chess/store/game.ex b/lib/chess/store/game.ex
index 636c72c..7b92c12 100644
--- a/lib/chess/store/game.ex
+++ b/lib/chess/store/game.ex
@@ -37,6 +37,7 @@ defmodule Chess.Store.Game do
def for_user(query, user) do
query
|> where([game], user_id: ^user.id)
+ |> preload(:opponent)
end
def ordered(query) do
diff --git a/lib/chess_web/templates/game/index.html.eex b/lib/chess_web/templates/game/index.html.eex
index c9f4c7c..71aafb7 100644
--- a/lib/chess_web/templates/game/index.html.eex
+++ b/lib/chess_web/templates/game/index.html.eex
@@ -5,7 +5,10 @@
<%= for game <- @games do %>
|
- <%= link "Started on #{Timex.format!(game.inserted_at, "%b %e at %I:%M %P", :strftime)}", to: game_path(@conn, :show, game), class: "btn btn-default btn-xs" %>
+ <%= link "Game with #{game.opponent.username}", to: game_path(@conn, :show, game), class: "btn btn-default btn-xs" %>
+ |
+
+ Started on <%= Timex.format!(game.inserted_at, "%b %e at %I:%M %P", :strftime) %>
|
<%= link "Delete", to: game_path(@conn, :delete, game), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>
diff --git a/test/features/games_test.exs b/test/features/games_test.exs
index c70c751..728b88c 100644
--- a/test/features/games_test.exs
+++ b/test/features/games_test.exs
@@ -41,6 +41,7 @@ defmodule Chess.GamesTest do
session
|> assert_has(css(".table tr", count: 1))
+ |> assert_has(link("Game with urbosa"))
end
test "can move a piece", %{session: session} do
|