Skip to content

Commit

Permalink
fix(ex/test): make tests against user data dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
firestack committed Nov 7, 2024
1 parent 259fa4a commit d6093ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions test/skate_web/controllers/detours_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ defmodule SkateWeb.DetoursControllerTest do

describe "detour/2" do
@tag :authenticated
test "fetches single detour with its state from database", %{conn: conn} do
test "fetches single detour with its state from database", %{
conn: conn,
user: %{email: email}
} do
populate_db_and_get_user(conn)

conn = get(conn, "/api/detours/1")
Expand All @@ -206,7 +209,7 @@ defmodule SkateWeb.DetoursControllerTest do

assert %{
"data" => %{
"author" => "[email protected]",
"author" => ^email,
"state" => %{
"context" => %{
"nearestIntersection" => "Street A & Avenue B",
Expand Down
8 changes: 4 additions & 4 deletions test/skate_web/controllers/page_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ defmodule SkateWeb.PageControllerTest do
end

@tag :authenticated
test "correct username set", %{conn: conn} do
test "correct username set", %{conn: conn, user: %{username: username}} do
conn = get(conn, "/")
assert html_response(conn, 200) =~ "<meta name=\"username\" content=\"test_user\">"
assert html_response(conn, 200) =~ "<meta name=\"username\" content=\"#{username}\">"
end

@tag :authenticated
test "correct email address set", %{conn: conn} do
test "correct email address set", %{conn: conn, user: %{email: email}} do
conn = get(conn, "/")

assert html_response(conn, 200) =~
"data-email-address=\"[email protected]\""
"data-email-address=\"#{email}\""
end

@tag :authenticated
Expand Down

0 comments on commit d6093ab

Please sign in to comment.