Fix tests.
This commit is contained in:
@@ -35,6 +35,5 @@ defmodule Runosaari.Registration.Performer do
|
|||||||
:photo_path,
|
:photo_path,
|
||||||
:confirmed
|
:confirmed
|
||||||
])
|
])
|
||||||
|> unique_constraint(:email)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,19 +8,51 @@ defmodule Runosaari.RegistrationTest do
|
|||||||
|
|
||||||
@create_attrs %{
|
@create_attrs %{
|
||||||
name: "some name",
|
name: "some name",
|
||||||
desc: "some description",
|
paragraph1: "some paragraph 1",
|
||||||
|
paragraph2: "some paragraph 2",
|
||||||
|
paragraph3: "some paragraph 3",
|
||||||
|
paragraph4: "some paragraph 4",
|
||||||
|
paragraph5: "some paragraph 5",
|
||||||
|
link: "some link",
|
||||||
|
photo_path: "some photo path",
|
||||||
confirmed: false
|
confirmed: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@update_attrs %{
|
@update_attrs %{
|
||||||
name: "some updated name",
|
name: "some updated name",
|
||||||
desc: "some updated description",
|
paragraph1: "some updated paragraph 1",
|
||||||
|
paragraph2: "some updated paragraph 2",
|
||||||
|
paragraph3: "some updated paragraph 3",
|
||||||
|
paragraph4: "some updated paragraph 4",
|
||||||
|
paragraph5: "some updated paragraph 5",
|
||||||
|
link: "some updated link",
|
||||||
|
photo_path: "some updated photo path",
|
||||||
confirmed: true
|
confirmed: true
|
||||||
}
|
}
|
||||||
|
|
||||||
@valid_attrs %{name: "some name", desc: "some description", confirmed: false}
|
@valid_attrs %{
|
||||||
|
name: "some name",
|
||||||
|
paragraph1: "some paragraph 1",
|
||||||
|
paragraph2: "some paragraph 2",
|
||||||
|
paragraph3: "some paragraph 3",
|
||||||
|
paragraph4: "some paragraph 4",
|
||||||
|
paragraph5: "some paragraph 5",
|
||||||
|
link: "some link",
|
||||||
|
photo_path: "some photo path",
|
||||||
|
confirmed: false
|
||||||
|
}
|
||||||
|
|
||||||
@invalid_attrs %{name: nil, desc: nil, confirmed: nil}
|
@invalid_attrs %{
|
||||||
|
name: nil,
|
||||||
|
paragraph1: nil,
|
||||||
|
paragraph2: nil,
|
||||||
|
paragraph3: nil,
|
||||||
|
paragraph4: nil,
|
||||||
|
paragraph5: nil,
|
||||||
|
link: nil,
|
||||||
|
photo_path: nil,
|
||||||
|
confirmed: false
|
||||||
|
}
|
||||||
|
|
||||||
def performer_fixture(attrs \\ %{}) do
|
def performer_fixture(attrs \\ %{}) do
|
||||||
{:ok, performer} =
|
{:ok, performer} =
|
||||||
@@ -44,7 +76,13 @@ defmodule Runosaari.RegistrationTest do
|
|||||||
test "create_performer/1 with valid data creates a performer" do
|
test "create_performer/1 with valid data creates a performer" do
|
||||||
assert {:ok, %Performer{} = performer} = Registration.create_performer(@valid_attrs)
|
assert {:ok, %Performer{} = performer} = Registration.create_performer(@valid_attrs)
|
||||||
assert performer.name == "some name"
|
assert performer.name == "some name"
|
||||||
assert performer.desc == "some description"
|
assert performer.paragraph1 == "some paragraph 1"
|
||||||
|
assert performer.paragraph2 == "some paragraph 2"
|
||||||
|
assert performer.paragraph3 == "some paragraph 3"
|
||||||
|
assert performer.paragraph4 == "some paragraph 4"
|
||||||
|
assert performer.paragraph5 == "some paragraph 5"
|
||||||
|
assert performer.link == "some link"
|
||||||
|
assert performer.photo_path == "some photo path"
|
||||||
assert performer.confirmed == false
|
assert performer.confirmed == false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,7 +97,13 @@ defmodule Runosaari.RegistrationTest do
|
|||||||
Registration.update_performer(performer, @update_attrs)
|
Registration.update_performer(performer, @update_attrs)
|
||||||
|
|
||||||
assert performer.name == "some updated name"
|
assert performer.name == "some updated name"
|
||||||
assert performer.desc == "some updated description"
|
assert performer.paragraph1 == "some updated paragraph 1"
|
||||||
|
assert performer.paragraph2 == "some updated paragraph 2"
|
||||||
|
assert performer.paragraph3 == "some updated paragraph 3"
|
||||||
|
assert performer.paragraph4 == "some updated paragraph 4"
|
||||||
|
assert performer.paragraph5 == "some updated paragraph 5"
|
||||||
|
assert performer.link == "some updated link"
|
||||||
|
assert performer.photo_path == "some updated photo path"
|
||||||
assert performer.confirmed == true
|
assert performer.confirmed == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ defmodule RunosaariWeb.IndexControllerTest do
|
|||||||
describe "index" do
|
describe "index" do
|
||||||
test "lists all index_paragraphs", %{conn: conn} do
|
test "lists all index_paragraphs", %{conn: conn} do
|
||||||
conn = get(conn, Routes.index_path(conn, :index))
|
conn = get(conn, Routes.index_path(conn, :index))
|
||||||
assert html_response(conn, 200) =~ "Listing Index paragraphs"
|
assert html_response(conn, 200) =~ "Runosaari 2021"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "new index" do
|
describe "new index" do
|
||||||
test "renders form", %{conn: conn} do
|
test "renders form", %{conn: conn} do
|
||||||
conn = get(conn, Routes.admin_index_path(conn, :new))
|
conn = get(conn, Routes.admin_index_path(conn, :new))
|
||||||
assert html_response(conn, 200) =~ "New Index"
|
assert html_response(conn, 200) =~ "Luo kappale"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -34,12 +34,12 @@ defmodule RunosaariWeb.IndexControllerTest do
|
|||||||
assert redirected_to(conn) == Routes.admin_index_path(conn, :show, id)
|
assert redirected_to(conn) == Routes.admin_index_path(conn, :show, id)
|
||||||
|
|
||||||
conn = get(conn, Routes.admin_index_path(conn, :show, id))
|
conn = get(conn, Routes.admin_index_path(conn, :show, id))
|
||||||
assert html_response(conn, 200) =~ "Show Index"
|
assert html_response(conn, 200) =~ "Kappaleen 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.admin_index_path(conn, :create), index: @invalid_attrs)
|
conn = post(conn, Routes.admin_index_path(conn, :create), index: @invalid_attrs)
|
||||||
assert html_response(conn, 200) =~ "New Index"
|
assert html_response(conn, 200) =~ "Luo kappale"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ defmodule RunosaariWeb.IndexControllerTest do
|
|||||||
|
|
||||||
test "renders form for editing chosen index", %{conn: conn, index: index} do
|
test "renders form for editing chosen index", %{conn: conn, index: index} do
|
||||||
conn = get(conn, Routes.admin_index_path(conn, :edit, index))
|
conn = get(conn, Routes.admin_index_path(conn, :edit, index))
|
||||||
assert html_response(conn, 200) =~ "Edit Index"
|
assert html_response(conn, 200) =~ "Muokkaa kappaletta"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ defmodule RunosaariWeb.IndexControllerTest do
|
|||||||
|
|
||||||
test "renders errors when data is invalid", %{conn: conn, index: index} do
|
test "renders errors when data is invalid", %{conn: conn, index: index} do
|
||||||
conn = put(conn, Routes.admin_index_path(conn, :update, index), index: @invalid_attrs)
|
conn = put(conn, Routes.admin_index_path(conn, :update, index), index: @invalid_attrs)
|
||||||
assert html_response(conn, 200) =~ "Edit Index"
|
assert html_response(conn, 200) =~ "Muokkaa kappaletta"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,39 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
|||||||
|
|
||||||
@create_attrs %{
|
@create_attrs %{
|
||||||
name: "some name",
|
name: "some name",
|
||||||
desc: "some description",
|
paragraph1: "some paragraph 1",
|
||||||
confirmed: false,
|
paragraph2: "some paragraph 2",
|
||||||
seqnum: 1
|
paragraph3: "some paragraph 3",
|
||||||
|
paragraph4: "some paragraph 4",
|
||||||
|
paragraph5: "some paragraph 5",
|
||||||
|
link: "some link",
|
||||||
|
photo_path: "some photo path",
|
||||||
|
confirmed: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@update_attrs %{
|
@update_attrs %{
|
||||||
name: "some updated name",
|
name: "some updated name",
|
||||||
desc: "some updated description",
|
paragraph1: "some updated paragraph 1",
|
||||||
confirmed: true,
|
paragraph2: "some updated paragraph 2",
|
||||||
seqnum: 2
|
paragraph3: "some updated paragraph 3",
|
||||||
|
paragraph4: "some updated paragraph 4",
|
||||||
|
paragraph5: "some updated paragraph 5",
|
||||||
|
link: "some updated link",
|
||||||
|
photo_path: "some updated photo path",
|
||||||
|
confirmed: true
|
||||||
}
|
}
|
||||||
|
|
||||||
@invalid_attrs %{name: nil, desc: nil, confirmed: nil, seqnum: nil}
|
@invalid_attrs %{
|
||||||
|
name: nil,
|
||||||
|
paragraph1: nil,
|
||||||
|
paragraph2: nil,
|
||||||
|
paragraph3: nil,
|
||||||
|
paragraph4: nil,
|
||||||
|
paragraph5: nil,
|
||||||
|
link: nil,
|
||||||
|
photo_path: nil,
|
||||||
|
confirmed: nil
|
||||||
|
}
|
||||||
|
|
||||||
def fixture(:performer) do
|
def fixture(:performer) do
|
||||||
{:ok, performer} = Registration.create_performer(@create_attrs)
|
{:ok, performer} = Registration.create_performer(@create_attrs)
|
||||||
@@ -34,12 +54,12 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
|||||||
describe "new performer" do
|
describe "new performer" do
|
||||||
test "renders form", %{conn: conn} do
|
test "renders form", %{conn: conn} do
|
||||||
conn = get(conn, Routes.admin_performer_path(conn, :new))
|
conn = get(conn, Routes.admin_performer_path(conn, :new))
|
||||||
assert html_response(conn, 200) =~ "Ilmoittaudu"
|
assert html_response(conn, 200) =~ "Luo esiintyjä"
|
||||||
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 admin when data is valid", %{conn: conn} do
|
||||||
conn = post(conn, Routes.admin_performer_path(conn, :create), performer: @create_attrs)
|
conn = post(conn, Routes.admin_performer_path(conn, :create), performer: @create_attrs)
|
||||||
|
|
||||||
assert redirected_to(conn) == Routes.admin_performer_path(conn, :admin)
|
assert redirected_to(conn) == Routes.admin_performer_path(conn, :admin)
|
||||||
@@ -50,7 +70,7 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
|||||||
|
|
||||||
test "renders errors when data is invalid", %{conn: conn} do
|
test "renders errors when data is invalid", %{conn: conn} do
|
||||||
conn = post(conn, Routes.admin_performer_path(conn, :create), performer: @invalid_attrs)
|
conn = post(conn, Routes.admin_performer_path(conn, :create), performer: @invalid_attrs)
|
||||||
assert html_response(conn, 200) =~ "Ilmoittaudu"
|
assert html_response(conn, 200) =~ "Luo esiintyjä"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -66,13 +86,13 @@ defmodule RunosaariWeb.PerformerControllerTest do
|
|||||||
describe "update performer" do
|
describe "update performer" do
|
||||||
setup [:create_performer]
|
setup [:create_performer]
|
||||||
|
|
||||||
test "redirects when data is valid", %{conn: conn, performer: performer} do
|
test "redirects to admin when data is valid", %{conn: conn, performer: performer} do
|
||||||
conn =
|
conn =
|
||||||
put(conn, Routes.admin_performer_path(conn, :update, performer), performer: @update_attrs)
|
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.admin_performer_path(conn, :admin)
|
||||||
|
|
||||||
conn = get(conn, Routes.performer_path(conn, :show, performer))
|
conn = get(conn, Routes.admin_performer_path(conn, :admin))
|
||||||
assert html_response(conn, 200) =~ "some updated name"
|
assert html_response(conn, 200) =~ "some updated name"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user