Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ex/test/conn-case): make default user dynamic from factory #2875

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ defmodule SkateWeb.ConnCase do

use ExUnit.CaseTemplate
import Plug.Test
alias Skate.Settings.User

using do
quote do
Expand All @@ -36,17 +35,12 @@ defmodule SkateWeb.ConnCase do
setup tags do
Skate.DataCase.setup_sandbox(tags)

username = "test_user"
email = "[email protected]"

user = User.upsert(username, email)
user = Skate.Factory.insert(:user)
resource = %{id: user.id}

{conn, user} =
cond do
tags[:authenticated] ->
User.upsert(username, email)

conn =
Phoenix.ConnTest.build_conn()
|> init_test_session(%{})
Expand All @@ -55,8 +49,6 @@ defmodule SkateWeb.ConnCase do
{conn, user}

tags[:authenticated_admin] ->
User.upsert(username, email)

conn =
Phoenix.ConnTest.build_conn()
|> init_test_session(%{})
Expand All @@ -67,8 +59,6 @@ defmodule SkateWeb.ConnCase do
{conn, user}

tags[:authenticated_dispatcher] ->
User.upsert(username, email)

conn =
Phoenix.ConnTest.build_conn()
|> init_test_session(%{})
Expand Down
Loading