Fix tests.
This commit is contained in:
@@ -3,6 +3,6 @@ defmodule RunosaariWeb.PageControllerTest do
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, "/")
|
||||
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
|
||||
assert html_response(conn, 200) =~ "Runosaari 2021"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,8 +3,16 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
|
||||
alias Runosaari.Schedule
|
||||
|
||||
@create_attrs %{description: "some description", notes: "some notes", time: ~N[2010-04-17 14:00:00]}
|
||||
@update_attrs %{description: "some updated description", notes: "some updated notes", time: ~N[2011-05-18 15:01:01]}
|
||||
@create_attrs %{
|
||||
description: "some description",
|
||||
notes: "some notes",
|
||||
time: ~N[2010-04-17 14:00:00]
|
||||
}
|
||||
@update_attrs %{
|
||||
description: "some updated description",
|
||||
notes: "some updated notes",
|
||||
time: ~N[2011-05-18 15:01:01]
|
||||
}
|
||||
@invalid_attrs %{description: nil, notes: nil, time: nil}
|
||||
|
||||
def fixture(:performance) do
|
||||
@@ -21,14 +29,14 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
|
||||
describe "new performance" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.performance_path(conn, :new))
|
||||
conn = get(conn, Routes.admin_performance_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Performance"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create performance" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.performance_path(conn, :create), performance: @create_attrs)
|
||||
conn = post(conn, Routes.admin_performance_path(conn, :create), performance: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.performance_path(conn, :show, id)
|
||||
@@ -38,7 +46,7 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.performance_path(conn, :create), performance: @invalid_attrs)
|
||||
conn = post(conn, Routes.admin_performance_path(conn, :create), performance: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Performance"
|
||||
end
|
||||
end
|
||||
@@ -47,7 +55,7 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
setup [:create_performance]
|
||||
|
||||
test "renders form for editing chosen performance", %{conn: conn, performance: performance} do
|
||||
conn = get(conn, Routes.performance_path(conn, :edit, performance))
|
||||
conn = get(conn, Routes.admin_performance_path(conn, :edit, performance))
|
||||
assert html_response(conn, 200) =~ "Edit Performance"
|
||||
end
|
||||
end
|
||||
@@ -56,7 +64,11 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
setup [:create_performance]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, performance: performance} do
|
||||
conn = put(conn, Routes.performance_path(conn, :update, performance), performance: @update_attrs)
|
||||
conn =
|
||||
put(conn, Routes.admin_performance_path(conn, :update, performance),
|
||||
performance: @update_attrs
|
||||
)
|
||||
|
||||
assert redirected_to(conn) == Routes.performance_path(conn, :show, performance)
|
||||
|
||||
conn = get(conn, Routes.performance_path(conn, :show, performance))
|
||||
@@ -64,7 +76,11 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, performance: performance} do
|
||||
conn = put(conn, Routes.performance_path(conn, :update, performance), performance: @invalid_attrs)
|
||||
conn =
|
||||
put(conn, Routes.admin_performance_path(conn, :update, performance),
|
||||
performance: @invalid_attrs
|
||||
)
|
||||
|
||||
assert html_response(conn, 200) =~ "Edit Performance"
|
||||
end
|
||||
end
|
||||
@@ -73,8 +89,9 @@ defmodule RunosaariWeb.PerformanceControllerTest do
|
||||
setup [:create_performance]
|
||||
|
||||
test "deletes chosen performance", %{conn: conn, performance: performance} do
|
||||
conn = delete(conn, Routes.performance_path(conn, :delete, performance))
|
||||
assert redirected_to(conn) == Routes.performance_path(conn, :index)
|
||||
conn = delete(conn, Routes.admin_performance_path(conn, :delete, performance))
|
||||
assert redirected_to(conn) == Routes.admin_performance_path(conn, :admin)
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.performance_path(conn, :show, performance))
|
||||
end
|
||||
|
||||
@@ -8,19 +8,41 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
||||
email: "some email",
|
||||
fname: "some fname",
|
||||
lname: "some lname",
|
||||
notes: "some notes",
|
||||
tel: "some tel"
|
||||
tel: "some tel",
|
||||
desc: "some desc",
|
||||
date1: true,
|
||||
date2: true,
|
||||
date3: true,
|
||||
bus: true,
|
||||
accom: true
|
||||
}
|
||||
@update_attrs %{
|
||||
confirmed: false,
|
||||
email: "some updated email",
|
||||
fname: "some updated fname",
|
||||
lname: "some updated lname",
|
||||
notes: "some updated notes",
|
||||
tel: "some updated tel"
|
||||
tel: "some updated tel",
|
||||
desc: "some updated desc",
|
||||
date1: true,
|
||||
date2: true,
|
||||
date3: true,
|
||||
bus: true,
|
||||
accom: true
|
||||
}
|
||||
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, tel: nil}
|
||||
|
||||
@invalid_attrs %{
|
||||
confirmed: nil,
|
||||
email: nil,
|
||||
fname: nil,
|
||||
lname: nil,
|
||||
tel: nil,
|
||||
desc: nil,
|
||||
date1: nil,
|
||||
date2: nil,
|
||||
date3: nil,
|
||||
bus: nil,
|
||||
accom: nil
|
||||
}
|
||||
def fixture(:performer) do
|
||||
{:ok, performer} = Registration.create_performer(@create_attrs)
|
||||
performer
|
||||
@@ -29,31 +51,31 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
||||
describe "index" do
|
||||
test "lists all performers", %{conn: conn} do
|
||||
conn = get(conn, Routes.performer_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Performers"
|
||||
assert html_response(conn, 200) =~ "Esiintyjät"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new performer" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.performer_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Performer"
|
||||
conn = get(conn, Routes.admin_performer_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "Ilmoittaudu"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create performer" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.performer_path(conn, :create), performer: @create_attrs)
|
||||
conn = post(conn, Routes.admin_performer_path(conn, :create), performer: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.performer_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.performer_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Show Performer"
|
||||
assert html_response(conn, 200) =~ "Esiintyjän tiedot"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.performer_path(conn, :create), performer: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Performer"
|
||||
conn = post(conn, Routes.admin_performer_path(conn, :create), performer: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Ilmoittaudu"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,8 +83,8 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
||||
setup [:create_performer]
|
||||
|
||||
test "renders form for editing chosen performer", %{conn: conn, performer: performer} do
|
||||
conn = get(conn, Routes.performer_path(conn, :edit, performer))
|
||||
assert html_response(conn, 200) =~ "Edit Performer"
|
||||
conn = get(conn, Routes.admin_performer_path(conn, :edit, performer))
|
||||
assert html_response(conn, 200) =~ "Muokkaa esiintyjän tietoja"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,7 +92,9 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
||||
setup [:create_performer]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, performer: performer} do
|
||||
conn = put(conn, Routes.performer_path(conn, :update, performer), performer: @update_attrs)
|
||||
conn =
|
||||
put(conn, Routes.admin_performer_path(conn, :update, performer), performer: @update_attrs)
|
||||
|
||||
assert redirected_to(conn) == Routes.performer_path(conn, :show, performer)
|
||||
|
||||
conn = get(conn, Routes.performer_path(conn, :show, performer))
|
||||
@@ -78,8 +102,10 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, performer: performer} do
|
||||
conn = put(conn, Routes.performer_path(conn, :update, performer), performer: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Performer"
|
||||
conn =
|
||||
put(conn, Routes.admin_performer_path(conn, :update, performer), performer: @invalid_attrs)
|
||||
|
||||
assert html_response(conn, 200) =~ "Muokkaa esiintyjän tietoja"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,8 +113,8 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
||||
setup [:create_performer]
|
||||
|
||||
test "deletes chosen performer", %{conn: conn, performer: performer} do
|
||||
conn = delete(conn, Routes.performer_path(conn, :delete, performer))
|
||||
assert redirected_to(conn) == Routes.performer_path(conn, :index)
|
||||
conn = delete(conn, Routes.admin_performer_path(conn, :delete, performer))
|
||||
assert redirected_to(conn) == Routes.admin_performer_path(conn, :admin)
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.performer_path(conn, :show, performer))
|
||||
|
||||
Reference in New Issue
Block a user