87 lines
2.8 KiB
Elixir
87 lines
2.8 KiB
Elixir
defmodule OutlookWeb.ArtikelControllerTest do
|
|
use OutlookWeb.ConnCase
|
|
|
|
# TODO: make this work
|
|
|
|
import Outlook.PublicFixtures
|
|
|
|
@create_attrs %{date: "some date", public_content: "some public_content", teaser: "some teaser", title: "some title", translator: "some translator", unauthorized: true}
|
|
@update_attrs %{date: "some updated date", public_content: "some updated public_content", teaser: "some updated teaser", title: "some updated title", translator: "some updated translator", unauthorized: false}
|
|
@invalid_attrs %{date: nil, public_content: nil, teaser: nil, title: nil, translator: nil, unauthorized: nil}
|
|
|
|
describe "index" do
|
|
test "lists all artikel", %{conn: conn} do
|
|
conn = get(conn, ~p"/artikel")
|
|
assert html_response(conn, 200) =~ "Listing Artikel"
|
|
end
|
|
end
|
|
|
|
describe "new artikel" do
|
|
test "renders form", %{conn: conn} do
|
|
conn = get(conn, ~p"/artikel/new")
|
|
assert html_response(conn, 200) =~ "New Artikel"
|
|
end
|
|
end
|
|
|
|
describe "create artikel" do
|
|
test "redirects to show when data is valid", %{conn: conn} do
|
|
conn = post(conn, ~p"/artikel", artikel: @create_attrs)
|
|
|
|
assert %{id: id} = redirected_params(conn)
|
|
assert redirected_to(conn) == ~p"/artikel/#{id}"
|
|
|
|
conn = get(conn, ~p"/artikel/#{id}")
|
|
assert html_response(conn, 200) =~ "Artikel #{id}"
|
|
end
|
|
|
|
test "renders errors when data is invalid", %{conn: conn} do
|
|
conn = post(conn, ~p"/artikel", artikel: @invalid_attrs)
|
|
assert html_response(conn, 200) =~ "New Artikel"
|
|
end
|
|
end
|
|
|
|
describe "edit artikel" do
|
|
setup [:create_artikel]
|
|
|
|
test "renders form for editing chosen artikel", %{conn: conn, artikel: artikel} do
|
|
conn = get(conn, ~p"/artikel/#{artikel}/edit")
|
|
assert html_response(conn, 200) =~ "Edit Artikel"
|
|
end
|
|
end
|
|
|
|
describe "update artikel" do
|
|
setup [:create_artikel]
|
|
|
|
test "redirects when data is valid", %{conn: conn, artikel: artikel} do
|
|
conn = put(conn, ~p"/artikel/#{artikel}", artikel: @update_attrs)
|
|
assert redirected_to(conn) == ~p"/artikel/#{artikel}"
|
|
|
|
conn = get(conn, ~p"/artikel/#{artikel}")
|
|
assert html_response(conn, 200) =~ "some updated date"
|
|
end
|
|
|
|
test "renders errors when data is invalid", %{conn: conn, artikel: artikel} do
|
|
conn = put(conn, ~p"/artikel/#{artikel}", artikel: @invalid_attrs)
|
|
assert html_response(conn, 200) =~ "Edit Artikel"
|
|
end
|
|
end
|
|
|
|
describe "delete artikel" do
|
|
setup [:create_artikel]
|
|
|
|
test "deletes chosen artikel", %{conn: conn, artikel: artikel} do
|
|
conn = delete(conn, ~p"/artikel/#{artikel}")
|
|
assert redirected_to(conn) == ~p"/artikel"
|
|
|
|
assert_error_sent 404, fn ->
|
|
get(conn, ~p"/artikel/#{artikel}")
|
|
end
|
|
end
|
|
end
|
|
|
|
defp create_artikel(_) do
|
|
artikel = artikel_fixture()
|
|
%{artikel: artikel}
|
|
end
|
|
end
|