From 34a3d48260d81a320f933af54327f6b12e8c7285 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Sat, 10 Dec 2016 23:28:18 +0000 Subject: [PATCH] Fix the fucking tests --- config/test.exs | 2 -- test/controllers/game_controller_test.exs | 33 +++-------------------- test/controllers/page_controller_test.exs | 8 ------ web/controllers/page_controller.ex | 7 ----- web/router.ex | 2 +- web/templates/game/index.html.eex | 2 +- 6 files changed, 6 insertions(+), 48 deletions(-) delete mode 100644 test/controllers/page_controller_test.exs delete mode 100644 web/controllers/page_controller.ex diff --git a/config/test.exs b/config/test.exs index 583056e..0b4ba41 100644 --- a/config/test.exs +++ b/config/test.exs @@ -12,8 +12,6 @@ config :logger, level: :warn # Configure your database config :chess, Chess.Repo, adapter: Ecto.Adapters.Postgres, - username: "postgres", - password: "postgres", database: "chess_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox diff --git a/test/controllers/game_controller_test.exs b/test/controllers/game_controller_test.exs index bea84e5..95d4522 100644 --- a/test/controllers/game_controller_test.exs +++ b/test/controllers/game_controller_test.exs @@ -2,8 +2,7 @@ defmodule Chess.GameControllerTest do use Chess.ConnCase alias Chess.Game - @valid_attrs %{board: %{}} - @invalid_attrs %{} + @valid_attrs %{} test "lists all entries on index", %{conn: conn} do 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 conn = post conn, game_path(conn, :create), game: @valid_attrs - assert redirected_to(conn) == game_path(conn, :index) - assert Repo.get_by(Game, @valid_attrs) - 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" + game = Repo.one(Game) + assert redirected_to(conn) == game_path(conn, :show, game) end test "shows chosen resource", %{conn: conn} do game = Repo.insert! %Game{} conn = get conn, game_path(conn, :show, game) - assert html_response(conn, 200) =~ "Show game" + assert html_response(conn, 200) =~ "
" end test "renders page not found when id is nonexistent", %{conn: conn} do @@ -33,25 +27,6 @@ defmodule Chess.GameControllerTest do 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 game = Repo.insert! %Game{} conn = delete conn, game_path(conn, :delete, game) diff --git a/test/controllers/page_controller_test.exs b/test/controllers/page_controller_test.exs deleted file mode 100644 index c855bab..0000000 --- a/test/controllers/page_controller_test.exs +++ /dev/null @@ -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 diff --git a/web/controllers/page_controller.ex b/web/controllers/page_controller.ex deleted file mode 100644 index 2a2c7f8..0000000 --- a/web/controllers/page_controller.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule Chess.PageController do - use Chess.Web, :controller - - def index(conn, _params) do - render conn, "index.html" - end -end diff --git a/web/router.ex b/web/router.ex index ec8fdd0..7ddec5a 100644 --- a/web/router.ex +++ b/web/router.ex @@ -16,7 +16,7 @@ defmodule Chess.Router do scope "/", Chess do pipe_through :browser # Use the default browser stack - get "/", PageController, :index + get "/", GameController, :index resources "/games", GameController, only: [:create, :show, :delete] end diff --git a/web/templates/game/index.html.eex b/web/templates/game/index.html.eex index 1ec8690..62c7578 100644 --- a/web/templates/game/index.html.eex +++ b/web/templates/game/index.html.eex @@ -15,7 +15,7 @@ -<%= form_for @changeset, game_path(@conn, :create), fn f -> %> +<%= form_for @changeset, game_path(@conn, :create), fn _f -> %>
<%= submit "Create game", class: "btn btn-primary" %>