mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Show opponent on game screen
This commit is contained in:
parent
9b47a85d8f
commit
8634d7aa9f
@ -42,7 +42,10 @@ defmodule ChessWeb.GameController do
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
game = Repo.get!(Game, id)
|
||||
query = from(game in Game, preload: [:user, :opponent])
|
||||
game =
|
||||
query
|
||||
|> Repo.get!(id)
|
||||
|
||||
render(conn, "show.html", game: game)
|
||||
end
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
<h2>Game with <%= opponent(@conn, @game).username %></h2>
|
||||
|
||||
<p><%= link "Back to games", to: game_path(@conn, :index) %></p>
|
||||
|
||||
<div id="app" data-game-id="<%= @game.id %>">
|
||||
|
||||
@ -22,6 +22,7 @@ defmodule Chess.GamesTest do
|
||||
|> click(button("Create game"))
|
||||
|
||||
session
|
||||
|> assert_has(css("h2", text: "Game with zelda"))
|
||||
|> assert_has(css(".board"))
|
||||
end
|
||||
|
||||
@ -56,6 +57,12 @@ defmodule Chess.GamesTest do
|
||||
session
|
||||
|> assert_has(css(".table tr", count: 1))
|
||||
|> assert_has(link("Game with zelda"))
|
||||
|
||||
session
|
||||
|> click(link("Game with zelda"))
|
||||
|
||||
session
|
||||
|> assert_has(css("h2", text: "Game with zelda"))
|
||||
end
|
||||
|
||||
test "can move a piece", %{session: session} do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user