-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54824d2
commit d101dd3
Showing
1 changed file
with
6 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,33 +7,25 @@ defmodule BokkenWeb.AuthControllerTest do | |
{:ok, conn: put_req_header(conn, "accept", "application/json")} | ||
end | ||
|
||
describe "sign_up " do | ||
describe "sign_up" do | ||
test "sign_up new user when data is valid", %{conn: conn} do | ||
user_params = %{ | ||
email: "[email protected]", | ||
password: "password1234", | ||
role: "guardian" | ||
} | ||
user_params = params_for(:user) | ||
|
||
conn = post(conn, ~p"/api/auth/sign_up", user_params) | ||
|
||
assert json_response(conn, 201) | ||
end | ||
|
||
test "sign_up new user when data is invalid", %{conn: conn} do | ||
user_params = %{ | ||
email: "[email protected]", | ||
password: "password1234", | ||
role: "random" | ||
} | ||
user_params = params_for(:user, %{role: "random"}) | ||
|
||
conn = post(conn, ~p"/api/auth/sign_up", user_params) | ||
|
||
assert json_response(conn, 422) == %{"errors" => %{"role" => ["não é válido"]}} | ||
end | ||
end | ||
|
||
describe "sign_in " do | ||
describe "sign_in" do | ||
test "sign_in user when data is valid", %{conn: conn} do | ||
user = insert(:user) | ||
|
||
|
@@ -92,21 +84,15 @@ defmodule BokkenWeb.AuthControllerTest do | |
|
||
conn = put(conn, ~p"/api/auth/me", user: user_params) | ||
|
||
assert json_response(conn, 200) | ||
assert json_response(conn, 200)["verified"] == false | ||
end | ||
end | ||
|
||
describe "create" do | ||
setup [:login_as_guardian] | ||
|
||
test "create new guardian", %{conn: conn} do | ||
params = %{ | ||
first_name: "Daniel", | ||
last_name: "Pereira", | ||
email: "[email protected]", | ||
role: "guardian", | ||
mobile: "929 066 896" | ||
} | ||
params = params_for(:guardian) | ||
|
||
conn = post(conn, ~p"/api/auth/me", user: params) | ||
|
||
|