Initial commit
This commit is contained in:
88
test/confient_web/controllers/assignment_controller_test.exs
Normal file
88
test/confient_web/controllers/assignment_controller_test.exs
Normal file
@@ -0,0 +1,88 @@
|
||||
defmodule ConfientWeb.AssignmentControllerTest do
|
||||
use ConfientWeb.ConnCase
|
||||
|
||||
alias Confient.Works
|
||||
|
||||
@create_attrs %{due: ~D[2010-04-17], title: "some title"}
|
||||
@update_attrs %{due: ~D[2011-05-18], title: "some updated title"}
|
||||
@invalid_attrs %{due: nil, title: nil}
|
||||
|
||||
def fixture(:assignment) do
|
||||
{:ok, assignment} = Works.create_assignment(@create_attrs)
|
||||
assignment
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
test "lists all assignments", %{conn: conn} do
|
||||
conn = get(conn, Routes.assignment_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Assignments"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new assignment" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.assignment_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Assignment"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create assignment" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.assignment_path(conn, :create), assignment: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.assignment_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.assignment_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Show Assignment"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.assignment_path(conn, :create), assignment: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Assignment"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit assignment" do
|
||||
setup [:create_assignment]
|
||||
|
||||
test "renders form for editing chosen assignment", %{conn: conn, assignment: assignment} do
|
||||
conn = get(conn, Routes.assignment_path(conn, :edit, assignment))
|
||||
assert html_response(conn, 200) =~ "Edit Assignment"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update assignment" do
|
||||
setup [:create_assignment]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, assignment: assignment} do
|
||||
conn = put(conn, Routes.assignment_path(conn, :update, assignment), assignment: @update_attrs)
|
||||
assert redirected_to(conn) == Routes.assignment_path(conn, :show, assignment)
|
||||
|
||||
conn = get(conn, Routes.assignment_path(conn, :show, assignment))
|
||||
assert html_response(conn, 200) =~ "some updated title"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, assignment: assignment} do
|
||||
conn = put(conn, Routes.assignment_path(conn, :update, assignment), assignment: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Assignment"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete assignment" do
|
||||
setup [:create_assignment]
|
||||
|
||||
test "deletes chosen assignment", %{conn: conn, assignment: assignment} do
|
||||
conn = delete(conn, Routes.assignment_path(conn, :delete, assignment))
|
||||
assert redirected_to(conn) == Routes.assignment_path(conn, :index)
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.assignment_path(conn, :show, assignment))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_assignment(_) do
|
||||
assignment = fixture(:assignment)
|
||||
%{assignment: assignment}
|
||||
end
|
||||
end
|
||||
88
test/confient_web/controllers/class_controller_test.exs
Normal file
88
test/confient_web/controllers/class_controller_test.exs
Normal file
@@ -0,0 +1,88 @@
|
||||
defmodule ConfientWeb.ClassControllerTest do
|
||||
use ConfientWeb.ConnCase
|
||||
|
||||
alias Confient.School
|
||||
|
||||
@create_attrs %{name: "some name"}
|
||||
@update_attrs %{name: "some updated name"}
|
||||
@invalid_attrs %{name: nil}
|
||||
|
||||
def fixture(:class) do
|
||||
{:ok, class} = School.create_class(@create_attrs)
|
||||
class
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
test "lists all classes", %{conn: conn} do
|
||||
conn = get(conn, Routes.class_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Classes"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new class" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.class_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Class"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create class" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.class_path(conn, :create), class: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.class_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.class_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Show Class"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.class_path(conn, :create), class: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Class"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit class" do
|
||||
setup [:create_class]
|
||||
|
||||
test "renders form for editing chosen class", %{conn: conn, class: class} do
|
||||
conn = get(conn, Routes.class_path(conn, :edit, class))
|
||||
assert html_response(conn, 200) =~ "Edit Class"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update class" do
|
||||
setup [:create_class]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, class: class} do
|
||||
conn = put(conn, Routes.class_path(conn, :update, class), class: @update_attrs)
|
||||
assert redirected_to(conn) == Routes.class_path(conn, :show, class)
|
||||
|
||||
conn = get(conn, Routes.class_path(conn, :show, class))
|
||||
assert html_response(conn, 200) =~ "some updated name"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, class: class} do
|
||||
conn = put(conn, Routes.class_path(conn, :update, class), class: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Class"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete class" do
|
||||
setup [:create_class]
|
||||
|
||||
test "deletes chosen class", %{conn: conn, class: class} do
|
||||
conn = delete(conn, Routes.class_path(conn, :delete, class))
|
||||
assert redirected_to(conn) == Routes.class_path(conn, :index)
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.class_path(conn, :show, class))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_class(_) do
|
||||
class = fixture(:class)
|
||||
%{class: class}
|
||||
end
|
||||
end
|
||||
8
test/confient_web/controllers/page_controller_test.exs
Normal file
8
test/confient_web/controllers/page_controller_test.exs
Normal file
@@ -0,0 +1,8 @@
|
||||
defmodule ConfientWeb.PageControllerTest do
|
||||
use ConfientWeb.ConnCase
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, "/")
|
||||
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
|
||||
end
|
||||
end
|
||||
88
test/confient_web/controllers/student_controller_test.exs
Normal file
88
test/confient_web/controllers/student_controller_test.exs
Normal file
@@ -0,0 +1,88 @@
|
||||
defmodule ConfientWeb.StudentControllerTest do
|
||||
use ConfientWeb.ConnCase
|
||||
|
||||
alias Confient.School
|
||||
|
||||
@create_attrs %{firstname: "some firstname", lastname: "some lastname"}
|
||||
@update_attrs %{firstname: "some updated firstname", lastname: "some updated lastname"}
|
||||
@invalid_attrs %{firstname: nil, lastname: nil}
|
||||
|
||||
def fixture(:student) do
|
||||
{:ok, student} = School.create_student(@create_attrs)
|
||||
student
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
test "lists all students", %{conn: conn} do
|
||||
conn = get(conn, Routes.student_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Students"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new student" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.student_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New Student"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create student" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.student_path(conn, :create), student: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.student_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.student_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Show Student"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.student_path(conn, :create), student: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Student"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit student" do
|
||||
setup [:create_student]
|
||||
|
||||
test "renders form for editing chosen student", %{conn: conn, student: student} do
|
||||
conn = get(conn, Routes.student_path(conn, :edit, student))
|
||||
assert html_response(conn, 200) =~ "Edit Student"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update student" do
|
||||
setup [:create_student]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, student: student} do
|
||||
conn = put(conn, Routes.student_path(conn, :update, student), student: @update_attrs)
|
||||
assert redirected_to(conn) == Routes.student_path(conn, :show, student)
|
||||
|
||||
conn = get(conn, Routes.student_path(conn, :show, student))
|
||||
assert html_response(conn, 200) =~ "some updated firstname"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, student: student} do
|
||||
conn = put(conn, Routes.student_path(conn, :update, student), student: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Student"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete student" do
|
||||
setup [:create_student]
|
||||
|
||||
test "deletes chosen student", %{conn: conn, student: student} do
|
||||
conn = delete(conn, Routes.student_path(conn, :delete, student))
|
||||
assert redirected_to(conn) == Routes.student_path(conn, :index)
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.student_path(conn, :show, student))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_student(_) do
|
||||
student = fixture(:student)
|
||||
%{student: student}
|
||||
end
|
||||
end
|
||||
88
test/confient_web/controllers/user_controller_test.exs
Normal file
88
test/confient_web/controllers/user_controller_test.exs
Normal file
@@ -0,0 +1,88 @@
|
||||
defmodule ConfientWeb.UserControllerTest do
|
||||
use ConfientWeb.ConnCase
|
||||
|
||||
alias Confient.Account
|
||||
|
||||
@create_attrs %{encrypted_password: "some encrypted_password", username: "some username"}
|
||||
@update_attrs %{encrypted_password: "some updated encrypted_password", username: "some updated username"}
|
||||
@invalid_attrs %{encrypted_password: nil, username: nil}
|
||||
|
||||
def fixture(:user) do
|
||||
{:ok, user} = Account.create_user(@create_attrs)
|
||||
user
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
test "lists all users", %{conn: conn} do
|
||||
conn = get(conn, Routes.user_path(conn, :index))
|
||||
assert html_response(conn, 200) =~ "Listing Users"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new user" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, Routes.user_path(conn, :new))
|
||||
assert html_response(conn, 200) =~ "New User"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create user" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, Routes.user_path(conn, :create), user: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == Routes.user_path(conn, :show, id)
|
||||
|
||||
conn = get(conn, Routes.user_path(conn, :show, id))
|
||||
assert html_response(conn, 200) =~ "Show User"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, Routes.user_path(conn, :create), user: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New User"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit user" do
|
||||
setup [:create_user]
|
||||
|
||||
test "renders form for editing chosen user", %{conn: conn, user: user} do
|
||||
conn = get(conn, Routes.user_path(conn, :edit, user))
|
||||
assert html_response(conn, 200) =~ "Edit User"
|
||||
end
|
||||
end
|
||||
|
||||
describe "update user" do
|
||||
setup [:create_user]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, user: user} do
|
||||
conn = put(conn, Routes.user_path(conn, :update, user), user: @update_attrs)
|
||||
assert redirected_to(conn) == Routes.user_path(conn, :show, user)
|
||||
|
||||
conn = get(conn, Routes.user_path(conn, :show, user))
|
||||
assert html_response(conn, 200) =~ "some updated encrypted_password"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, user: user} do
|
||||
conn = put(conn, Routes.user_path(conn, :update, user), user: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit User"
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete user" do
|
||||
setup [:create_user]
|
||||
|
||||
test "deletes chosen user", %{conn: conn, user: user} do
|
||||
conn = delete(conn, Routes.user_path(conn, :delete, user))
|
||||
assert redirected_to(conn) == Routes.user_path(conn, :index)
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, Routes.user_path(conn, :show, user))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp create_user(_) do
|
||||
user = fixture(:user)
|
||||
%{user: user}
|
||||
end
|
||||
end
|
||||
14
test/confient_web/views/error_view_test.exs
Normal file
14
test/confient_web/views/error_view_test.exs
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule ConfientWeb.ErrorViewTest do
|
||||
use ConfientWeb.ConnCase, async: true
|
||||
|
||||
# Bring render/3 and render_to_string/3 for testing custom views
|
||||
import Phoenix.View
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(ConfientWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(ConfientWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
||||
8
test/confient_web/views/layout_view_test.exs
Normal file
8
test/confient_web/views/layout_view_test.exs
Normal file
@@ -0,0 +1,8 @@
|
||||
defmodule ConfientWeb.LayoutViewTest do
|
||||
use ConfientWeb.ConnCase, async: true
|
||||
|
||||
# When testing helpers, you may want to import Phoenix.HTML and
|
||||
# use functions such as safe_to_string() to convert the helper
|
||||
# result into an HTML string.
|
||||
# import Phoenix.HTML
|
||||
end
|
||||
3
test/confient_web/views/page_view_test.exs
Normal file
3
test/confient_web/views/page_view_test.exs
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule ConfientWeb.PageViewTest do
|
||||
use ConfientWeb.ConnCase, async: true
|
||||
end
|
||||
Reference in New Issue
Block a user