refactored for new project name
This commit is contained in:
parent
0039146cd4
commit
82ab1d1ea5
113 changed files with 417 additions and 412 deletions
test
shift73k
shift73k_web
controllers
user_auth_test.exsuser_confirmation_controller_test.exsuser_registration_controller_test.exsuser_reset_password_controller_test.exsuser_session_controller_test.exsuser_settings_controller_test.exs
live
admin_dashboard_live_test.exspage_live_test.exsproperty_live_test.exs
user
user_dashboard_live_test.exsviews
support
test_helper.exs
|
@ -1,9 +1,9 @@
|
|||
defmodule Bones73k.AccountsTest do
|
||||
use Bones73k.DataCase
|
||||
defmodule Shift73k.AccountsTest do
|
||||
use Shift73k.DataCase
|
||||
|
||||
alias Bones73k.Accounts
|
||||
import Bones73k.AccountsFixtures
|
||||
alias Bones73k.Accounts.{User, UserToken}
|
||||
alias Shift73k.Accounts
|
||||
import Shift73k.AccountsFixtures
|
||||
alias Shift73k.Accounts.{User, UserToken}
|
||||
|
||||
describe "get_user_by_email/1" do
|
||||
test "does not return the user if the email does not exist" do
|
|
@ -1,11 +1,11 @@
|
|||
defmodule Bones73k.PropertiesTest do
|
||||
use Bones73k.DataCase
|
||||
defmodule Shift73k.PropertiesTest do
|
||||
use Shift73k.DataCase
|
||||
|
||||
alias Bones73k.Properties
|
||||
import Bones73k.AccountsFixtures
|
||||
alias Shift73k.Properties
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
describe "properties" do
|
||||
alias Bones73k.Properties.Property
|
||||
alias Shift73k.Properties.Property
|
||||
|
||||
@valid_attrs %{description: "some description", name: "some name", price: "120.5"}
|
||||
@update_attrs %{
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bones73kWeb.UserAuthTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.UserAuthTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
alias Bones73k.Accounts
|
||||
alias Bones73kWeb.UserAuth
|
||||
import Bones73k.AccountsFixtures
|
||||
alias Shift73k.Accounts
|
||||
alias Shift73kWeb.UserAuth
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
setup %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> Map.replace!(:secret_key_base, Bones73kWeb.Endpoint.config(:secret_key_base))
|
||||
|> Map.replace!(:secret_key_base, Shift73kWeb.Endpoint.config(:secret_key_base))
|
||||
|> init_test_session(%{})
|
||||
|
||||
%{user: user_fixture(), conn: conn}
|
||||
|
@ -63,7 +63,7 @@ defmodule Bones73kWeb.UserAuthTest do
|
|||
|
||||
test "broadcasts to the given live_socket_id", %{conn: conn} do
|
||||
live_socket_id = "users_sessions:abcdef-token"
|
||||
Bones73kWeb.Endpoint.subscribe(live_socket_id)
|
||||
Shift73kWeb.Endpoint.subscribe(live_socket_id)
|
||||
|
||||
conn
|
||||
|> put_session(:live_socket_id, live_socket_id)
|
|
@ -1,9 +1,9 @@
|
|||
defmodule Bones73kWeb.UserConfirmationControllerTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.UserConfirmationControllerTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
alias Bones73k.Accounts
|
||||
alias Bones73k.Repo
|
||||
import Bones73k.AccountsFixtures
|
||||
alias Shift73k.Accounts
|
||||
alias Shift73k.Repo
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
setup do
|
||||
%{user: user_fixture()}
|
|
@ -1,7 +1,7 @@
|
|||
defmodule Bones73kWeb.UserRegistrationControllerTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.UserRegistrationControllerTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
describe "GET /users/register" do
|
||||
test "renders registration page", %{conn: conn} do
|
|
@ -1,9 +1,9 @@
|
|||
defmodule Bones73kWeb.UserResetPasswordControllerTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.UserResetPasswordControllerTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
alias Bones73k.Accounts
|
||||
alias Bones73k.Repo
|
||||
import Bones73k.AccountsFixtures
|
||||
alias Shift73k.Accounts
|
||||
alias Shift73k.Repo
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
setup do
|
||||
%{user: user_fixture()}
|
|
@ -1,7 +1,7 @@
|
|||
defmodule Bones73kWeb.UserSessionControllerTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.UserSessionControllerTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
setup do
|
||||
%{user: user_fixture()}
|
|
@ -1,8 +1,8 @@
|
|||
defmodule Bones73kWeb.UserSettingsControllerTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.UserSettingsControllerTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
alias Bones73k.Accounts
|
||||
import Bones73k.AccountsFixtures
|
||||
alias Shift73k.Accounts
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
setup :register_and_log_in_user
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
defmodule Bones73kWeb.AdminDashboardLiveTest do
|
||||
use Bones73kWeb.ConnCase
|
||||
defmodule Shift73kWeb.AdminDashboardLiveTest do
|
||||
use Shift73kWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
test "disconnected and connected render without authentication should redirect to login page",
|
||||
%{conn: conn} do
|
||||
|
@ -38,7 +38,7 @@ defmodule Bones73kWeb.AdminDashboardLiveTest do
|
|||
assert disconnected_html =~ "Welcome to the admin dashboard!"
|
||||
assert render(admin_dashboard) =~ "Welcome to the admin dashboard!"
|
||||
|
||||
Bones73k.Accounts.logout_user(admin)
|
||||
Shift73k.Accounts.logout_user(admin)
|
||||
|
||||
# Assert our liveview process is down
|
||||
ref = Process.monitor(admin_dashboard.pid)
|
||||
|
@ -67,7 +67,7 @@ defmodule Bones73kWeb.AdminDashboardLiveTest do
|
|||
assert disconnected_html =~ "Welcome to the admin dashboard!"
|
||||
assert render(admin_dashboard) =~ "Welcome to the admin dashboard!"
|
||||
|
||||
Bones73k.Accounts.logout_user(admin2)
|
||||
Shift73k.Accounts.logout_user(admin2)
|
||||
|
||||
# Assert our liveview is alive
|
||||
ref = Process.monitor(admin_dashboard.pid)
|
|
@ -1,8 +1,8 @@
|
|||
defmodule Bones73kWeb.PageLiveTest do
|
||||
use Bones73kWeb.ConnCase
|
||||
defmodule Shift73kWeb.PageLiveTest do
|
||||
use Shift73kWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
test "disconnected and connected render with authentication should redirect to index page", %{
|
||||
conn: conn
|
||||
|
@ -24,7 +24,7 @@ defmodule Bones73kWeb.PageLiveTest do
|
|||
assert disconnected_html =~ "Welcome to Phoenix!"
|
||||
assert render(page_live) =~ "Welcome to Phoenix!"
|
||||
|
||||
Bones73k.Accounts.logout_user(user)
|
||||
Shift73k.Accounts.logout_user(user)
|
||||
|
||||
# Assert our liveview process is down
|
||||
ref = Process.monitor(page_live.pid)
|
||||
|
@ -53,7 +53,7 @@ defmodule Bones73kWeb.PageLiveTest do
|
|||
assert disconnected_html =~ "Welcome to Phoenix!"
|
||||
assert render(page_live) =~ "Welcome to Phoenix!"
|
||||
|
||||
Bones73k.Accounts.logout_user(user1)
|
||||
Shift73k.Accounts.logout_user(user1)
|
||||
|
||||
# Assert our liveview is alive
|
||||
ref = Process.monitor(page_live.pid)
|
|
@ -1,10 +1,10 @@
|
|||
defmodule Bones73kWeb.PropertyLiveTest do
|
||||
use Bones73kWeb.ConnCase
|
||||
defmodule Shift73kWeb.PropertyLiveTest do
|
||||
use Shift73kWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
alias Bones73k.Properties
|
||||
alias Shift73k.Properties
|
||||
|
||||
@create_attrs %{description: "some description", name: "some name", price: "120.5"}
|
||||
@update_attrs %{
|
||||
|
@ -208,7 +208,7 @@ defmodule Bones73kWeb.PropertyLiveTest do
|
|||
assert html =~ "Listing Properties"
|
||||
assert render(index_live) =~ "Listing Properties"
|
||||
|
||||
Bones73k.Accounts.logout_user(user)
|
||||
Shift73k.Accounts.logout_user(user)
|
||||
|
||||
# Assert our liveview process is down
|
||||
ref = Process.monitor(index_live.pid)
|
||||
|
@ -238,7 +238,7 @@ defmodule Bones73kWeb.PropertyLiveTest do
|
|||
assert html =~ "Listing Properties"
|
||||
assert render(index_live) =~ "Listing Properties"
|
||||
|
||||
Bones73k.Accounts.logout_user(user1)
|
||||
Shift73k.Accounts.logout_user(user1)
|
||||
|
||||
# Assert our liveview is alive
|
||||
ref = Process.monitor(index_live.pid)
|
||||
|
@ -366,7 +366,7 @@ defmodule Bones73kWeb.PropertyLiveTest do
|
|||
assert html =~ property.description
|
||||
assert render(show_live) =~ property.description
|
||||
|
||||
Bones73k.Accounts.logout_user(user)
|
||||
Shift73k.Accounts.logout_user(user)
|
||||
|
||||
# Assert our liveview process is down
|
||||
ref = Process.monitor(show_live.pid)
|
||||
|
@ -395,7 +395,7 @@ defmodule Bones73kWeb.PropertyLiveTest do
|
|||
assert html =~ property.description
|
||||
assert render(show_live) =~ property.description
|
||||
|
||||
Bones73k.Accounts.logout_user(user1)
|
||||
Shift73k.Accounts.logout_user(user1)
|
||||
|
||||
# Assert our liveview is alive
|
||||
ref = Process.monitor(show_live.pid)
|
|
@ -1,11 +1,11 @@
|
|||
defmodule Bones73kWeb.UserLive.RegistrationTest do
|
||||
use Bones73kWeb.ConnCase
|
||||
defmodule Shift73kWeb.UserLive.RegistrationTest do
|
||||
use Shift73kWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
alias Bones73k.Accounts
|
||||
alias Bones73k.Accounts.User
|
||||
alias Shift73k.Accounts
|
||||
alias Shift73k.Accounts.User
|
||||
|
||||
describe "Registration" do
|
||||
setup %{conn: conn} do
|
||||
|
@ -15,14 +15,14 @@ defmodule Bones73kWeb.UserLive.RegistrationTest do
|
|||
end
|
||||
|
||||
test "displays registration form", %{conn: conn} do
|
||||
{:ok, _view, html} = live_isolated(conn, Bones73kWeb.UserLive.Registration)
|
||||
{:ok, _view, html} = live_isolated(conn, Shift73kWeb.UserLive.Registration)
|
||||
|
||||
assert html =~ "Register\n </h2>"
|
||||
assert html =~ "Email</label>"
|
||||
end
|
||||
|
||||
test "render errors for invalid data", %{conn: conn} do
|
||||
{:ok, view, _html} = live_isolated(conn, Bones73kWeb.UserLive.Registration)
|
||||
{:ok, view, _html} = live_isolated(conn, Shift73kWeb.UserLive.Registration)
|
||||
|
||||
html =
|
||||
view
|
||||
|
@ -40,7 +40,7 @@ defmodule Bones73kWeb.UserLive.RegistrationTest do
|
|||
conn: conn,
|
||||
user_return_to: user_return_to
|
||||
} do
|
||||
{:ok, view, html} = live_isolated(conn, Bones73kWeb.UserLive.Registration)
|
||||
{:ok, view, html} = live_isolated(conn, Shift73kWeb.UserLive.Registration)
|
||||
|
||||
# Login trigger form not triggered yet
|
||||
refute html =~ "phx-trigger-action=\"phx-trigger-action\""
|
||||
|
@ -59,7 +59,7 @@ defmodule Bones73kWeb.UserLive.RegistrationTest do
|
|||
|
||||
# Collect the rendered login params token
|
||||
[params_token] = Floki.attribute(html, "input#user_params_token", "value")
|
||||
{:ok, params} = Phoenix.Token.decrypt(Bones73kWeb.Endpoint, "login_params", params_token)
|
||||
{:ok, params} = Phoenix.Token.decrypt(Shift73kWeb.Endpoint, "login_params", params_token)
|
||||
%{user_id: param_user_id, user_return_to: param_return_path} = params
|
||||
|
||||
# Token in login trigger form has correct user ID?
|
|
@ -1,12 +1,12 @@
|
|||
defmodule Bones73kWeb.UserLive.ResetPasswordTest do
|
||||
use Bones73kWeb.ConnCase
|
||||
defmodule Shift73kWeb.UserLive.ResetPasswordTest do
|
||||
use Shift73kWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
alias Bones73k.Repo
|
||||
alias Bones73k.Accounts
|
||||
alias Bones73k.Accounts.{User, UserToken}
|
||||
alias Shift73k.Repo
|
||||
alias Shift73k.Accounts
|
||||
alias Shift73k.Accounts.{User, UserToken}
|
||||
|
||||
setup %{conn: conn} do
|
||||
user = user_fixture()
|
||||
|
@ -15,7 +15,7 @@ defmodule Bones73kWeb.UserLive.ResetPasswordTest do
|
|||
end
|
||||
|
||||
test "displays registration form", %{conn: conn, user: user} do
|
||||
{:ok, _view, html} = live_isolated(conn, Bones73kWeb.UserLive.ResetPassword)
|
||||
{:ok, _view, html} = live_isolated(conn, Shift73kWeb.UserLive.ResetPassword)
|
||||
|
||||
assert html =~ "Reset password\n </h2>"
|
||||
assert html =~ user.email
|
||||
|
@ -23,7 +23,7 @@ defmodule Bones73kWeb.UserLive.ResetPasswordTest do
|
|||
end
|
||||
|
||||
test "render errors for invalid data", %{conn: conn} do
|
||||
{:ok, view, _html} = live_isolated(conn, Bones73kWeb.UserLive.ResetPassword)
|
||||
{:ok, view, _html} = live_isolated(conn, Shift73kWeb.UserLive.ResetPassword)
|
||||
|
||||
form_data = %{"user" => %{"password" => "abc", "password_confirmation" => "def"}}
|
||||
html = form(view, "#pw_reset_form", form_data) |> render_change()
|
||||
|
@ -36,7 +36,7 @@ defmodule Bones73kWeb.UserLive.ResetPasswordTest do
|
|||
|
||||
@tag :capture_log
|
||||
test "saves new password once", %{conn: conn, user: user} do
|
||||
{:ok, view, _html} = live_isolated(conn, Bones73kWeb.UserLive.ResetPassword)
|
||||
{:ok, view, _html} = live_isolated(conn, Shift73kWeb.UserLive.ResetPassword)
|
||||
|
||||
# Render submitting a new password
|
||||
new_pw = "valid_new_pass_123"
|
|
@ -1,8 +1,8 @@
|
|||
defmodule Bones73kWeb.UserDashboardLiveTest do
|
||||
use Bones73kWeb.ConnCase
|
||||
defmodule Shift73kWeb.UserDashboardLiveTest do
|
||||
use Shift73kWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import Bones73k.AccountsFixtures
|
||||
import Shift73k.AccountsFixtures
|
||||
|
||||
test "disconnected and connected render without authentication should redirect to login page",
|
||||
%{conn: conn} do
|
||||
|
@ -40,7 +40,7 @@ defmodule Bones73kWeb.UserDashboardLiveTest do
|
|||
assert disconnected_html =~ "Welcome to the user dashboard!"
|
||||
assert render(user_dashboard) =~ "Welcome to the user dashboard!"
|
||||
|
||||
Bones73k.Accounts.logout_user(user)
|
||||
Shift73k.Accounts.logout_user(user)
|
||||
|
||||
# Assert our liveview process is down
|
||||
ref = Process.monitor(user_dashboard.pid)
|
||||
|
@ -69,7 +69,7 @@ defmodule Bones73kWeb.UserDashboardLiveTest do
|
|||
assert disconnected_html =~ "Welcome to the user dashboard!"
|
||||
assert render(user_dashboard) =~ "Welcome to the user dashboard!"
|
||||
|
||||
Bones73k.Accounts.logout_user(user2)
|
||||
Shift73k.Accounts.logout_user(user2)
|
||||
|
||||
# Assert our liveview is alive
|
||||
ref = Process.monitor(user_dashboard.pid)
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bones73kWeb.ErrorViewTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.ErrorViewTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
# Bring render/3 and render_to_string/3 for testing custom views
|
||||
import Phoenix.View
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(Bones73kWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
assert render_to_string(Shift73kWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(Bones73kWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
assert render_to_string(Shift73kWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Bones73kWeb.LayoutViewTest do
|
||||
use Bones73kWeb.ConnCase, async: true
|
||||
defmodule Shift73kWeb.LayoutViewTest do
|
||||
use Shift73kWeb.ConnCase, async: true
|
||||
|
||||
# When testing helpers, you may want to import Phoenix.HTML and
|
||||
# use functions such as safe_to_string() to convert the helper
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Bones73kWeb.ChannelCase do
|
||||
defmodule Shift73kWeb.ChannelCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
channel tests.
|
||||
|
@ -11,7 +11,7 @@ defmodule Bones73kWeb.ChannelCase do
|
|||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use Bones73kWeb.ChannelCase, async: true`, although
|
||||
by setting `use Shift73kWeb.ChannelCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
|
@ -21,18 +21,18 @@ defmodule Bones73kWeb.ChannelCase do
|
|||
quote do
|
||||
# Import conveniences for testing with channels
|
||||
import Phoenix.ChannelTest
|
||||
import Bones73kWeb.ChannelCase
|
||||
import Shift73kWeb.ChannelCase
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint Bones73kWeb.Endpoint
|
||||
@endpoint Shift73kWeb.Endpoint
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo)
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Shift73k.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()})
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
:ok
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Bones73kWeb.ConnCase do
|
||||
defmodule Shift73kWeb.ConnCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
tests that require setting up a connection.
|
||||
|
@ -11,7 +11,7 @@ defmodule Bones73kWeb.ConnCase do
|
|||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use Bones73kWeb.ConnCase, async: true`, although
|
||||
by setting `use Shift73kWeb.ConnCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
|
@ -22,20 +22,20 @@ defmodule Bones73kWeb.ConnCase do
|
|||
# Import conveniences for testing with connections
|
||||
import Plug.Conn
|
||||
import Phoenix.ConnTest
|
||||
import Bones73kWeb.ConnCase
|
||||
import Shift73kWeb.ConnCase
|
||||
|
||||
alias Bones73kWeb.Router.Helpers, as: Routes
|
||||
alias Shift73kWeb.Router.Helpers, as: Routes
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint Bones73kWeb.Endpoint
|
||||
@endpoint Shift73kWeb.Endpoint
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo)
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Shift73k.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()})
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
|
@ -50,7 +50,7 @@ defmodule Bones73kWeb.ConnCase do
|
|||
test context.
|
||||
"""
|
||||
def register_and_log_in_user(%{conn: conn}) do
|
||||
user = Bones73k.AccountsFixtures.user_fixture()
|
||||
user = Shift73k.AccountsFixtures.user_fixture()
|
||||
%{conn: log_in_user(conn, user), user: user}
|
||||
end
|
||||
|
||||
|
@ -60,7 +60,7 @@ defmodule Bones73kWeb.ConnCase do
|
|||
It returns an updated `conn`.
|
||||
"""
|
||||
def log_in_user(conn, user) do
|
||||
token = Bones73k.Accounts.generate_user_session_token(user)
|
||||
token = Shift73k.Accounts.generate_user_session_token(user)
|
||||
|
||||
conn
|
||||
|> Phoenix.ConnTest.init_test_session(%{})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Bones73k.DataCase do
|
||||
defmodule Shift73k.DataCase do
|
||||
@moduledoc """
|
||||
This module defines the setup for tests requiring
|
||||
access to the application's data layer.
|
||||
|
@ -10,7 +10,7 @@ defmodule Bones73k.DataCase do
|
|||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use Bones73k.DataCase, async: true`, although
|
||||
by setting `use Shift73k.DataCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
|
@ -18,20 +18,20 @@ defmodule Bones73k.DataCase do
|
|||
|
||||
using do
|
||||
quote do
|
||||
alias Bones73k.Repo
|
||||
alias Shift73k.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import Bones73k.DataCase
|
||||
import Shift73k.DataCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo)
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Shift73k.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()})
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
:ok
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
defmodule Bones73k.AccountsFixtures do
|
||||
defmodule Shift73k.AccountsFixtures do
|
||||
@moduledoc """
|
||||
This module defines test helpers for creating
|
||||
entities via the `Bones73k.Accounts` context.
|
||||
entities via the `Shift73k.Accounts` context.
|
||||
"""
|
||||
|
||||
def unique_user_email, do: "user#{System.unique_integer()}@example.com"
|
||||
|
@ -14,7 +14,7 @@ defmodule Bones73k.AccountsFixtures do
|
|||
email: unique_user_email(),
|
||||
password: valid_user_password()
|
||||
})
|
||||
|> Bones73k.Accounts.register_user()
|
||||
|> Shift73k.Accounts.register_user()
|
||||
|
||||
user
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ defmodule Bones73k.AccountsFixtures do
|
|||
email: unique_user_email(),
|
||||
password: valid_user_password()
|
||||
})
|
||||
|> Bones73k.Accounts.register_user()
|
||||
|> Shift73k.Accounts.register_user()
|
||||
|
||||
user
|
||||
end
|
||||
|
@ -42,7 +42,7 @@ defmodule Bones73k.AccountsFixtures do
|
|||
end
|
||||
|
||||
def login_params_token(user, return_path) do
|
||||
Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", %{
|
||||
Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", %{
|
||||
user_id: user.id,
|
||||
user_return_to: return_path,
|
||||
messages: [
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
ExUnit.start()
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, :manual)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Shift73k.Repo, :manual)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue