Packages
torch
3.0.0
6.0.0
5.6.0
5.5.0
5.4.0
5.3.2
5.3.1
5.2.0
5.1.2
5.1.1
5.1.0
5.0.0
5.0.0-rc.4
5.0.0-rc.3
5.0.0-rc.2
5.0.0-rc.1
5.0.0-rc.0
4.3.2
4.3.1
4.3.0
4.2.1
4.2.0
retired
4.1.0
4.0.0
4.0.0-rc.0
3.9.1
3.9.0
3.8.0
3.7.1
3.7.0-rc.0
3.6.4
3.6.3
3.6.2
3.6.1
3.6.0
3.5.0
3.4.1
3.4.0
3.3.1
3.3.0
3.2.1
3.2.0
3.1.0
3.0.0
2.1.0
2.0.0
2.0.0-rc.3
2.0.0-rc.2
2.0.0-rc.1
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
0.2.0-rc.5
0.2.0-rc.4
0.2.0-rc.3
0.2.0-rc.2
0.2.0-rc.1
0.1.0
Rapid admin generator for Phoenix
Current section
Files
Jump to
Current section
Files
priv/templates/eex/phx.gen.html/controller_test.exs
defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ControllerTest do
use <%= inspect context.web_module %>.ConnCase
alias <%= inspect context.module %>
@create_attrs <%= inspect schema.params.create %>
@update_attrs <%= inspect schema.params.update %>
@invalid_attrs <%= inspect for {key, _} <- schema.params.create, into: %{}, do: {key, nil} %>
def fixture(:<%= schema.singular %>) do
{:ok, <%= schema.singular %>} = <%= inspect context.alias %>.create_<%= schema.singular %>(@create_attrs)
<%= schema.singular %>
end
describe "index" do
test "lists all <%= schema.plural %>", %{conn: conn} do
conn = get conn, Routes.<%= schema.route_helper %>_path(conn, :index)
assert html_response(conn, 200) =~ "<%= schema.human_plural %>"
end
end
describe "new <%= schema.singular %>" do
test "renders form", %{conn: conn} do
conn = get conn, Routes.<%= schema.route_helper %>_path(conn, :new)
assert html_response(conn, 200) =~ "New <%= schema.human_singular %>"
end
end
describe "create <%= schema.singular %>" do
test "redirects to show when data is valid", %{conn: conn} do
conn = post conn, Routes.<%= schema.route_helper %>_path(conn, :create), <%= schema.singular %>: @create_attrs
assert %{id: id} = redirected_params(conn)
assert redirected_to(conn) == Routes.<%= schema.route_helper %>_path(conn, :show, id)
conn = get conn, Routes.<%= schema.route_helper %>_path(conn, :show, id)
assert html_response(conn, 200) =~ "<%= schema.human_singular %> Details"
end
test "renders errors when data is invalid", %{conn: conn} do
conn = post conn, Routes.<%= schema.route_helper %>_path(conn, :create), <%= schema.singular %>: @invalid_attrs
assert html_response(conn, 200) =~ "New <%= schema.human_singular %>"
end
end
describe "edit <%= schema.singular %>" do
setup [:create_<%= schema.singular %>]
test "renders form for editing chosen <%= schema.singular %>", %{conn: conn, <%= schema.singular %>: <%= schema.singular %>} do
conn = get conn, Routes.<%= schema.route_helper %>_path(conn, :edit, <%= schema.singular %>)
assert html_response(conn, 200) =~ "Edit <%= schema.human_singular %>"
end
end
describe "update <%= schema.singular %>" do
setup [:create_<%= schema.singular %>]
test "redirects when data is valid", %{conn: conn, <%= schema.singular %>: <%= schema.singular %>} do
conn = put conn, Routes.<%= schema.route_helper %>_path(conn, :update, <%= schema.singular %>), <%= schema.singular %>: @update_attrs
assert redirected_to(conn) == Routes.<%= schema.route_helper %>_path(conn, :show, <%= schema.singular %>)
conn = get conn, Routes.<%= schema.route_helper %>_path(conn, :show, <%= schema.singular %>)<%= if schema.string_attr do %>
assert html_response(conn, 200) =~ <%= inspect Mix.Phoenix.Schema.default_param(schema, :update) %><% else %>
assert html_response(conn, 200)<% end %>
end
test "renders errors when data is invalid", %{conn: conn, <%= schema.singular %>: <%= schema.singular %>} do
conn = put conn, Routes.<%= schema.route_helper %>_path(conn, :update, <%= schema.singular %>), <%= schema.singular %>: @invalid_attrs
assert html_response(conn, 200) =~ "Edit <%= schema.human_singular %>"
end
end
describe "delete <%= schema.singular %>" do
setup [:create_<%= schema.singular %>]
test "deletes chosen <%= schema.singular %>", %{conn: conn, <%= schema.singular %>: <%= schema.singular %>} do
conn = delete conn, Routes.<%= schema.route_helper %>_path(conn, :delete, <%= schema.singular %>)
assert redirected_to(conn) == Routes.<%= schema.route_helper %>_path(conn, :index)
assert_error_sent 404, fn ->
get conn, Routes.<%= schema.route_helper %>_path(conn, :show, <%= schema.singular %>)
end
end
end
defp create_<%= schema.singular %>(_) do
<%= schema.singular %> = fixture(:<%= schema.singular %>)
{:ok, <%= schema.singular %>: <%= schema.singular %>}
end
end