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:
parent
8f19a086df
commit
b122c4d44f
@ -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
|
||||
|
||||
@ -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" %>
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user