Skip to content

Commit

Permalink
Add suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsp45 committed Oct 6, 2023
1 parent 54824d2 commit fe426b1
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions test/bokken_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit fe426b1

Please sign in to comment.