Autogen registration UI.
This commit is contained in:
76
test/runosaari/registration_test.exs
Normal file
76
test/runosaari/registration_test.exs
Normal file
@@ -0,0 +1,76 @@
|
||||
defmodule Runosaari.RegistrationTest do
|
||||
use Runosaari.DataCase
|
||||
|
||||
alias Runosaari.Registration
|
||||
|
||||
describe "performers" do
|
||||
alias Runosaari.Registration.Performer
|
||||
|
||||
@valid_attrs %{confirmed: true, email: "some email", fname: "some fname", lname: "some lname", notes: "some notes", performerId: 42, tel: "some tel"}
|
||||
@update_attrs %{confirmed: false, email: "some updated email", fname: "some updated fname", lname: "some updated lname", notes: "some updated notes", performerId: 43, tel: "some updated tel"}
|
||||
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, performerId: nil, tel: nil}
|
||||
|
||||
def performer_fixture(attrs \\ %{}) do
|
||||
{:ok, performer} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Registration.create_performer()
|
||||
|
||||
performer
|
||||
end
|
||||
|
||||
test "list_performers/0 returns all performers" do
|
||||
performer = performer_fixture()
|
||||
assert Registration.list_performers() == [performer]
|
||||
end
|
||||
|
||||
test "get_performer!/1 returns the performer with given id" do
|
||||
performer = performer_fixture()
|
||||
assert Registration.get_performer!(performer.id) == performer
|
||||
end
|
||||
|
||||
test "create_performer/1 with valid data creates a performer" do
|
||||
assert {:ok, %Performer{} = performer} = Registration.create_performer(@valid_attrs)
|
||||
assert performer.confirmed == true
|
||||
assert performer.email == "some email"
|
||||
assert performer.fname == "some fname"
|
||||
assert performer.lname == "some lname"
|
||||
assert performer.notes == "some notes"
|
||||
assert performer.performerId == 42
|
||||
assert performer.tel == "some tel"
|
||||
end
|
||||
|
||||
test "create_performer/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Registration.create_performer(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_performer/2 with valid data updates the performer" do
|
||||
performer = performer_fixture()
|
||||
assert {:ok, %Performer{} = performer} = Registration.update_performer(performer, @update_attrs)
|
||||
assert performer.confirmed == false
|
||||
assert performer.email == "some updated email"
|
||||
assert performer.fname == "some updated fname"
|
||||
assert performer.lname == "some updated lname"
|
||||
assert performer.notes == "some updated notes"
|
||||
assert performer.performerId == 43
|
||||
assert performer.tel == "some updated tel"
|
||||
end
|
||||
|
||||
test "update_performer/2 with invalid data returns error changeset" do
|
||||
performer = performer_fixture()
|
||||
assert {:error, %Ecto.Changeset{}} = Registration.update_performer(performer, @invalid_attrs)
|
||||
assert performer == Registration.get_performer!(performer.id)
|
||||
end
|
||||
|
||||
test "delete_performer/1 deletes the performer" do
|
||||
performer = performer_fixture()
|
||||
assert {:ok, %Performer{}} = Registration.delete_performer(performer)
|
||||
assert_raise Ecto.NoResultsError, fn -> Registration.get_performer!(performer.id) end
|
||||
end
|
||||
|
||||
test "change_performer/1 returns a performer changeset" do
|
||||
performer = performer_fixture()
|
||||
assert %Ecto.Changeset{} = Registration.change_performer(performer)
|
||||
end
|
||||
end
|
||||
end
|
||||
88
test/runosaari_web/controllers/performer_controller_test.exs
Normal file
88
test/runosaari_web/controllers/performer_controller_test.exs
Normal file
@@ -0,0 +1,88 @@
|
||||
defmodule RunosaariWeb.PerformerControllerTest do
|
||||
use RunosaariWeb.ConnCase
|
||||
|
||||
alias Runosaari.Registration
|
||||
|
||||
@create_attrs %{confirmed: true, email: "some email", fname: "some fname", lname: "some lname", notes: "some notes", performerId: 42, tel: "some tel"}
|
||||
@update_attrs %{confirmed: false, email: "some updated email", fname: "some updated fname", lname: "some updated lname", notes: "some updated notes", performerId: 43, tel: "some updated tel"}
|
||||
@invalid_attrs %{confirmed: nil, email: nil, fname: nil, lname: nil, notes: nil, performerId: nil, tel: nil}
|
||||
|
||||
def fixture(:performer) do
|
||||
{:ok, performer} = Registration.create_performer(@create_attrs)
|
||||
performer
|
||||
end
|
||||
|
||||
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"
|
||||
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"
|
||||
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)
|
||||
|
||||
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"
|
||||
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"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit performer" 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"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update performer" 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)
|
||||
assert redirected_to(conn) == Routes.performer_path(conn, :show, performer)
|
||||
|
||||
conn = get(conn, Routes.performer_path(conn, :show, performer))
|
||||
assert html_response(conn, 200) =~ "some updated email"
|
||||
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"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete performer" 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)
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.performer_path(conn, :show, performer))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_performer(_) do
|
||||
performer = fixture(:performer)
|
||||
%{performer: performer}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user