Skip to content

Commit

Permalink
enhance admin guardian controller test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsp45 committed Nov 6, 2023
1 parent d1ae5bc commit b80df97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 6 additions & 5 deletions test/bokken_web/controllers/admin/guardian_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ defmodule BokkenWeb.Admin.GuardianControllerTest do
import Bokken.Factory

setup %{conn: conn} do
password = "password1234!"
guardian_user = insert(:user, role: "organizer", password: password)
event = insert(:event)

Check warning on line 9 in test/bokken_web/controllers/admin/guardian_controller_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.x / Elixir 1.14.x

variable "event" is unused (if the variable is not meant to be used, prefix it with an underscore)

{:ok, user} = Accounts.authenticate_user(guardian_user.email, password)

{:ok, conn: log_in_user(conn, user)}
{:ok, conn: put_resp_header(conn, "accept", "application/json")}
end

describe "index" do
setup [:login_as_organizer]

test "lists all guardians", %{conn: conn} do
conn = get(conn, ~p"/api/admin/guardians/")
assert json_response(conn, 200)["data"] == []
end
end

describe "show" do
setup [:login_as_organizer]

test "shoes", %{conn: conn} do
guardian = insert(:guardian)

Expand Down
18 changes: 13 additions & 5 deletions test/bokken_web/controllers/guardian_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ defmodule BokkenWeb.GuardianControllerTest do

import Bokken.Factory

setup %{conn: conn} do
password = "password1234!"
guardian_user = insert(:user, role: "guardian", password: password)
# setup %{conn: conn} do
# password = "password1234!"
# guardian_user = insert(:user, role: "guardian", password: password)

# {:ok, user} = Accounts.authenticate_user(guardian_user.email, password)

{:ok, user} = Accounts.authenticate_user(guardian_user.email, password)
# {:ok, conn: log_in_user(conn, user)}
# end

{:ok, conn: log_in_user(conn, user)}
setup %{conn: conn} do
event = insert(:event)

{:ok, conn: put_resp_header(conn, "accept", "application/json"), event: event}
end

describe "index" do
setup [:login_as_guardian]

test "lists all guardians", %{conn: conn} do

Check failure on line 27 in test/bokken_web/controllers/guardian_controller_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.x / Elixir 1.14.x

test index lists all guardians (BokkenWeb.GuardianControllerTest)
conn = get(conn, ~p"/api/guardians/")
assert json_response(conn, 200)["data"] == []
Expand Down

0 comments on commit b80df97

Please sign in to comment.