1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Games list shows opponent

This commit is contained in:
Daniel Barber 2018-02-19 11:02:13 -05:00
parent 8f19a086df
commit b122c4d44f
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
3 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -5,7 +5,10 @@
<%= for game <- @games do %>
<tr>
<td>
<%= 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" %>
</td>
<td>
Started on <%= Timex.format!(game.inserted_at, "%b %e at %I:%M %P", :strftime) %>
</td>
<td class="text-right">
<%= link "Delete", to: game_path(@conn, :delete, game), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>

View File

@ -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