Survival instructions editable.
This commit is contained in:
@@ -124,4 +124,65 @@ defmodule Runosaari.PagesTest do
|
||||
assert %Ecto.Changeset{} = Pages.change_info(info)
|
||||
end
|
||||
end
|
||||
|
||||
describe "survival_items" do
|
||||
alias Runosaari.Pages.Survival
|
||||
|
||||
@valid_attrs %{content: "some content", seqnum: 42}
|
||||
@update_attrs %{content: "some updated content", seqnum: 43}
|
||||
@invalid_attrs %{content: nil, seqnum: nil}
|
||||
|
||||
def survival_fixture(attrs \\ %{}) do
|
||||
{:ok, survival} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Pages.create_survival()
|
||||
|
||||
survival
|
||||
end
|
||||
|
||||
test "list_survival_items/0 returns all survival_items" do
|
||||
survival = survival_fixture()
|
||||
assert Pages.list_survival_items() == [survival]
|
||||
end
|
||||
|
||||
test "get_survival!/1 returns the survival with given id" do
|
||||
survival = survival_fixture()
|
||||
assert Pages.get_survival!(survival.id) == survival
|
||||
end
|
||||
|
||||
test "create_survival/1 with valid data creates a survival" do
|
||||
assert {:ok, %Survival{} = survival} = Pages.create_survival(@valid_attrs)
|
||||
assert survival.content == "some content"
|
||||
assert survival.seqnum == 42
|
||||
end
|
||||
|
||||
test "create_survival/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Pages.create_survival(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_survival/2 with valid data updates the survival" do
|
||||
survival = survival_fixture()
|
||||
assert {:ok, %Survival{} = survival} = Pages.update_survival(survival, @update_attrs)
|
||||
assert survival.content == "some updated content"
|
||||
assert survival.seqnum == 43
|
||||
end
|
||||
|
||||
test "update_survival/2 with invalid data returns error changeset" do
|
||||
survival = survival_fixture()
|
||||
assert {:error, %Ecto.Changeset{}} = Pages.update_survival(survival, @invalid_attrs)
|
||||
assert survival == Pages.get_survival!(survival.id)
|
||||
end
|
||||
|
||||
test "delete_survival/1 deletes the survival" do
|
||||
survival = survival_fixture()
|
||||
assert {:ok, %Survival{}} = Pages.delete_survival(survival)
|
||||
assert_raise Ecto.NoResultsError, fn -> Pages.get_survival!(survival.id) end
|
||||
end
|
||||
|
||||
test "change_survival/1 returns a survival changeset" do
|
||||
survival = survival_fixture()
|
||||
assert %Ecto.Changeset{} = Pages.change_survival(survival)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,14 +15,14 @@ defmodule RunosaariWeb.InfoControllerTest do
|
||||
describe "index" do
|
||||
test "lists all info_paragraphs", %{conn: conn} do
|
||||
conn = get(conn, Routes.info_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Info paragraphs"
|
||||
assert html_response(conn, 200) =~ "Info"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new info" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.info_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Info"
|
||||
assert html_response(conn, 200) =~ "Uusi info kappale"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,12 +34,12 @@ defmodule RunosaariWeb.InfoControllerTest do
|
||||
assert redirected_to(conn) == Routes.info_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.info_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Show Info"
|
||||
assert html_response(conn, 200) =~ "Kappaleen tiedot"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.info_path(conn, :create), info: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Info"
|
||||
assert html_response(conn, 200) =~ "Uusi info kappale"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,7 +48,7 @@ defmodule RunosaariWeb.InfoControllerTest do
|
||||
|
||||
test "renders form for editing chosen info", %{conn: conn, info: info} do
|
||||
conn = get(conn, Routes.info_path(conn, :edit, info))
|
||||
assert html_response(conn, 200) =~ "Edit Info"
|
||||
assert html_response(conn, 200) =~ "Muokkaa kappaletta"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ defmodule RunosaariWeb.InfoControllerTest do
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, info: info} do
|
||||
conn = put(conn, Routes.info_path(conn, :update, info), info: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Info"
|
||||
assert html_response(conn, 200) =~ "Muokkaa kappaletta"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,6 +75,7 @@ defmodule RunosaariWeb.InfoControllerTest do
|
||||
test "deletes chosen info", %{conn: conn, info: info} do
|
||||
conn = delete(conn, Routes.info_path(conn, :delete, info))
|
||||
assert redirected_to(conn) == Routes.info_path(conn, :index)
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.info_path(conn, :show, info))
|
||||
end
|
||||
|
||||
93
test/runosaari_web/controllers/survival_controller_test.exs
Normal file
93
test/runosaari_web/controllers/survival_controller_test.exs
Normal file
@@ -0,0 +1,93 @@
|
||||
defmodule RunosaariWeb.SurvivalControllerTest do
|
||||
use RunosaariWeb.ConnCase
|
||||
|
||||
alias Runosaari.Pages
|
||||
|
||||
@create_attrs %{content: "some content", seqnum: 42}
|
||||
@update_attrs %{content: "some updated content", seqnum: 43}
|
||||
@invalid_attrs %{content: nil, seqnum: nil}
|
||||
|
||||
def fixture(:survival) do
|
||||
{:ok, survival} = Pages.create_survival(@create_attrs)
|
||||
survival
|
||||
end
|
||||
|
||||
describe "admin" do
|
||||
test "lists all survival_items", %{conn: conn} do
|
||||
conn = get(conn, Routes.admin_survival_path(conn, :admin))
|
||||
assert html_response(conn, 200) =~ "HALLINTA - Survival listan kohdat"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new survival" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.admin_survival_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "Uusi survival listan kohta"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create survival" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.admin_survival_path(conn, :create), survival: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.admin_survival_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.admin_survival_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Survival listan kohdan tiedot"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.admin_survival_path(conn, :create), survival: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Uusi survival listan kohta"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit survival" do
|
||||
setup [:create_survival]
|
||||
|
||||
test "renders form for editing chosen survival", %{conn: conn, survival: survival} do
|
||||
conn = get(conn, Routes.admin_survival_path(conn, :edit, survival))
|
||||
assert html_response(conn, 200) =~ "Muokkaa survival listan kohtaa"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update survival" do
|
||||
setup [:create_survival]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, survival: survival} do
|
||||
conn =
|
||||
put(conn, Routes.admin_survival_path(conn, :update, survival), survival: @update_attrs)
|
||||
|
||||
assert redirected_to(conn) == Routes.admin_survival_path(conn, :show, survival)
|
||||
|
||||
conn = get(conn, Routes.admin_survival_path(conn, :show, survival))
|
||||
assert html_response(conn, 200) =~ "some updated content"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, survival: survival} do
|
||||
conn =
|
||||
put(conn, Routes.admin_survival_path(conn, :update, survival), survival: @invalid_attrs)
|
||||
|
||||
assert html_response(conn, 200) =~ "Muokkaa survival listan kohtaa"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete survival" do
|
||||
setup [:create_survival]
|
||||
|
||||
test "deletes chosen survival", %{conn: conn, survival: survival} do
|
||||
conn = delete(conn, Routes.admin_survival_path(conn, :delete, survival))
|
||||
assert redirected_to(conn) == Routes.admin_survival_path(conn, :admin)
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.admin_survival_path(conn, :show, survival))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_survival(_) do
|
||||
survival = fixture(:survival)
|
||||
%{survival: survival}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user