mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Fix the fucking tests
This commit is contained in:
parent
b5c7695344
commit
34a3d48260
@ -12,8 +12,6 @@ config :logger, level: :warn
|
|||||||
# Configure your database
|
# Configure your database
|
||||||
config :chess, Chess.Repo,
|
config :chess, Chess.Repo,
|
||||||
adapter: Ecto.Adapters.Postgres,
|
adapter: Ecto.Adapters.Postgres,
|
||||||
username: "postgres",
|
|
||||||
password: "postgres",
|
|
||||||
database: "chess_test",
|
database: "chess_test",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
pool: Ecto.Adapters.SQL.Sandbox
|
pool: Ecto.Adapters.SQL.Sandbox
|
||||||
|
|||||||
@ -2,8 +2,7 @@ defmodule Chess.GameControllerTest do
|
|||||||
use Chess.ConnCase
|
use Chess.ConnCase
|
||||||
|
|
||||||
alias Chess.Game
|
alias Chess.Game
|
||||||
@valid_attrs %{board: %{}}
|
@valid_attrs %{}
|
||||||
@invalid_attrs %{}
|
|
||||||
|
|
||||||
test "lists all entries on index", %{conn: conn} do
|
test "lists all entries on index", %{conn: conn} do
|
||||||
conn = get conn, game_path(conn, :index)
|
conn = get conn, game_path(conn, :index)
|
||||||
@ -12,19 +11,14 @@ defmodule Chess.GameControllerTest do
|
|||||||
|
|
||||||
test "creates resource and redirects when data is valid", %{conn: conn} do
|
test "creates resource and redirects when data is valid", %{conn: conn} do
|
||||||
conn = post conn, game_path(conn, :create), game: @valid_attrs
|
conn = post conn, game_path(conn, :create), game: @valid_attrs
|
||||||
assert redirected_to(conn) == game_path(conn, :index)
|
game = Repo.one(Game)
|
||||||
assert Repo.get_by(Game, @valid_attrs)
|
assert redirected_to(conn) == game_path(conn, :show, game)
|
||||||
end
|
|
||||||
|
|
||||||
test "does not create resource and renders errors when data is invalid", %{conn: conn} do
|
|
||||||
conn = post conn, game_path(conn, :create), game: @invalid_attrs
|
|
||||||
assert html_response(conn, 200) =~ "New game"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "shows chosen resource", %{conn: conn} do
|
test "shows chosen resource", %{conn: conn} do
|
||||||
game = Repo.insert! %Game{}
|
game = Repo.insert! %Game{}
|
||||||
conn = get conn, game_path(conn, :show, game)
|
conn = get conn, game_path(conn, :show, game)
|
||||||
assert html_response(conn, 200) =~ "Show game"
|
assert html_response(conn, 200) =~ "<div id=\"app\" data-game-id=\"#{game.id}\">"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders page not found when id is nonexistent", %{conn: conn} do
|
test "renders page not found when id is nonexistent", %{conn: conn} do
|
||||||
@ -33,25 +27,6 @@ defmodule Chess.GameControllerTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders form for editing chosen resource", %{conn: conn} do
|
|
||||||
game = Repo.insert! %Game{}
|
|
||||||
conn = get conn, game_path(conn, :edit, game)
|
|
||||||
assert html_response(conn, 200) =~ "Edit game"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "updates chosen resource and redirects when data is valid", %{conn: conn} do
|
|
||||||
game = Repo.insert! %Game{}
|
|
||||||
conn = put conn, game_path(conn, :update, game), game: @valid_attrs
|
|
||||||
assert redirected_to(conn) == game_path(conn, :show, game)
|
|
||||||
assert Repo.get_by(Game, @valid_attrs)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "does not update chosen resource and renders errors when data is invalid", %{conn: conn} do
|
|
||||||
game = Repo.insert! %Game{}
|
|
||||||
conn = put conn, game_path(conn, :update, game), game: @invalid_attrs
|
|
||||||
assert html_response(conn, 200) =~ "Edit game"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "deletes chosen resource", %{conn: conn} do
|
test "deletes chosen resource", %{conn: conn} do
|
||||||
game = Repo.insert! %Game{}
|
game = Repo.insert! %Game{}
|
||||||
conn = delete conn, game_path(conn, :delete, game)
|
conn = delete conn, game_path(conn, :delete, game)
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
defmodule Chess.PageControllerTest do
|
|
||||||
use Chess.ConnCase
|
|
||||||
|
|
||||||
test "GET /", %{conn: conn} do
|
|
||||||
conn = get conn, "/"
|
|
||||||
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
defmodule Chess.PageController do
|
|
||||||
use Chess.Web, :controller
|
|
||||||
|
|
||||||
def index(conn, _params) do
|
|
||||||
render conn, "index.html"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -16,7 +16,7 @@ defmodule Chess.Router do
|
|||||||
scope "/", Chess do
|
scope "/", Chess do
|
||||||
pipe_through :browser # Use the default browser stack
|
pipe_through :browser # Use the default browser stack
|
||||||
|
|
||||||
get "/", PageController, :index
|
get "/", GameController, :index
|
||||||
resources "/games", GameController, only: [:create, :show, :delete]
|
resources "/games", GameController, only: [:create, :show, :delete]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%= form_for @changeset, game_path(@conn, :create), fn f -> %>
|
<%= form_for @changeset, game_path(@conn, :create), fn _f -> %>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= submit "Create game", class: "btn btn-primary" %>
|
<%= submit "Create game", class: "btn btn-primary" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user