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