Rename module to `boardwise`.

pull/1/head
Joshua Potter 2023-11-30 10:25:00 -07:00
parent ba011253d8
commit 615509216a
40 changed files with 155 additions and 154 deletions

0
.githooks/pre-commit Executable file → Normal file
View File

2
.gitignore vendored
View File

@ -23,7 +23,7 @@ erl_crash.dump
/tmp/
# Ignore package tarball (built via "mix hex.build").
site-*.tar
boardwise-*.tar
# Ignore assets that are produced by build tools.
/priv/static/assets/

View File

@ -8,8 +8,8 @@ const path = require("path")
module.exports = {
content: [
"./js/**/*.js",
"../lib/site_web.ex",
"../lib/site_web/**/*.*ex"
"../lib/boardwise_web.ex",
"../lib/boardwise_web/**/*.*ex"
],
theme: {
extend: {

View File

@ -7,20 +7,21 @@
# General application configuration
import Config
config :site,
ecto_repos: [Site.Repo],
config :boardwise,
namespace: BoardWise,
ecto_repos: [BoardWise.Repo],
generators: [timestamp_type: :utc_datetime]
# Configures the endpoint
config :site, SiteWeb.Endpoint,
config :boardwise, BoardWiseWeb.Endpoint,
url: [host: "localhost"],
adapter: Phoenix.Endpoint.Cowboy2Adapter,
render_errors: [
formats: [html: SiteWeb.ErrorHTML, json: SiteWeb.ErrorJSON],
formats: [html: BoardWiseWeb.ErrorHTML, json: BoardWiseWeb.ErrorJSON],
layout: false
],
pubsub_server: Site.PubSub,
live_view: [signing_salt: "Wq4i8F/W"]
pubsub_server: BoardWise.PubSub,
live_view: [signing_salt: "NutZSMRk"]
# Configures the mailer
#
@ -29,7 +30,7 @@ config :site, SiteWeb.Endpoint,
#
# For production it's recommended to configure a different adapter
# at the `config/runtime.exs`.
config :site, Site.Mailer, adapter: Swoosh.Adapters.Local
config :boardwise, BoardWise.Mailer, adapter: Swoosh.Adapters.Local
# Configure esbuild (the version is required)
config :esbuild,

View File

@ -1,11 +1,11 @@
import Config
# Configure your database
config :site, Site.Repo,
config :boardwise, BoardWise.Repo,
username: "jrpotter",
password: "postgres",
hostname: "localhost",
database: "site_dev",
database: "boardwise_dev",
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10
@ -16,14 +16,14 @@ config :site, Site.Repo,
# The watchers configuration can be used to run external
# watchers to your application. For example, we can use it
# to bundle .js and .css sources.
config :site, SiteWeb.Endpoint,
config :boardwise, BoardWiseWeb.Endpoint,
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {127, 0, 0, 1}, port: 4000],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: "9o2fhxlaKOfOintGZYpUTa4dSiJoPdFk09Yju0mRhfLWsLP26L9i57TBzpe61qcT",
secret_key_base: "5hf4wAGNe1kUPI9qJ+YOA4+05hlFOY3QJRc0RqnXpt01XbR/e5ZCNQHIEO7TR9Uo",
watchers: [
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
@ -53,17 +53,17 @@ config :site, SiteWeb.Endpoint,
# different ports.
# Watch static and templates for browser reloading.
config :site, SiteWeb.Endpoint,
config :boardwise, BoardWiseWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/site_web/(controllers|live|components)/.*(ex|heex)$"
~r"lib/boardwise_web/(controllers|live|components)/.*(ex|heex)$"
]
]
# Enable dev routes for dashboard and mailbox
config :site, dev_routes: true
config :boardwise, dev_routes: true
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"

View File

@ -5,10 +5,10 @@ import Config
# manifest is generated by the `mix assets.deploy` task,
# which you should run after static files are built and
# before starting your production server.
config :site, SiteWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
config :boardwise, BoardWiseWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
# Configures Swoosh API Client
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Site.Finch
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: BoardWise.Finch
# Disable Swoosh Local Memory Storage
config :swoosh, local: false

View File

@ -12,12 +12,12 @@ import Config
# If you use `mix release`, you need to explicitly enable the server
# by passing the PHX_SERVER=true when you start it:
#
# PHX_SERVER=true bin/site start
# PHX_SERVER=true bin/boardwise start
#
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
# script that automatically sets the env var above.
if System.get_env("PHX_SERVER") do
config :site, SiteWeb.Endpoint, server: true
config :boardwise, BoardWiseWeb.Endpoint, server: true
end
if config_env() == :prod do
@ -30,7 +30,7 @@ if config_env() == :prod do
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
config :site, Site.Repo,
config :boardwise, BoardWise.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
@ -51,9 +51,9 @@ if config_env() == :prod do
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")
config :site, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
config :boardwise, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
config :site, SiteWeb.Endpoint,
config :boardwise, BoardWiseWeb.Endpoint,
url: [host: host, port: 443, scheme: "https"],
http: [
# Enable IPv6 and bind on all interfaces.
@ -70,7 +70,7 @@ if config_env() == :prod do
# To get SSL working, you will need to add the `https` key
# to your endpoint configuration:
#
# config :site, SiteWeb.Endpoint,
# config :boardwise, BoardWiseWeb.Endpoint,
# https: [
# ...,
# port: 443,
@ -92,7 +92,7 @@ if config_env() == :prod do
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :site, SiteWeb.Endpoint,
# config :boardwise, BoardWiseWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
@ -103,7 +103,7 @@ if config_env() == :prod do
# Also, you may need to configure the Swoosh API client of your choice if you
# are not using SMTP. Here is an example of the configuration:
#
# config :site, Site.Mailer,
# config :boardwise, BoardWise.Mailer,
# adapter: Swoosh.Adapters.Mailgun,
# api_key: System.get_env("MAILGUN_API_KEY"),
# domain: System.get_env("MAILGUN_DOMAIN")

View File

@ -5,23 +5,23 @@ import Config
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :site, Site.Repo,
config :boardwise, BoardWise.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "site_test#{System.get_env("MIX_TEST_PARTITION")}",
database: "boardwise_test#{System.get_env("MIX_TEST_PARTITION")}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: 10
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :site, SiteWeb.Endpoint,
config :boardwise, BoardWiseWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
secret_key_base: "T0jFDk3PWnwZCoYdv8l2ZgOk8thliSovjN++aOs6DWMKb7RP6dN+VNR7Ptnja1RW",
secret_key_base: "0Nt/alF0NScLRGMz58M9EOaiFrzuQjeMgwTo4QsBpqkJeRMw1MQvG0OIIgTZVEmF",
server: false
# In test we don't send emails.
config :site, Site.Mailer, adapter: Swoosh.Adapters.Test
config :boardwise, BoardWise.Mailer, adapter: Swoosh.Adapters.Test
# Disable swoosh api client as it is only required for production adapters.
config :swoosh, :api_client, false

View File

@ -32,7 +32,7 @@
{
packages = {
app = mixRelease {
pname = "site";
pname = "boardwise";
src = ./.;
version = "0.1.0";
mixNixDeps = deps;

View File

@ -1,6 +1,6 @@
defmodule Site do
defmodule BoardWise do
@moduledoc """
Site keeps the contexts that define your domain
BoardWise keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless

View File

@ -1,4 +1,4 @@
defmodule Site.Application do
defmodule BoardWise.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
@ -8,21 +8,21 @@ defmodule Site.Application do
@impl true
def start(_type, _args) do
children = [
SiteWeb.Telemetry,
Site.Repo,
{DNSCluster, query: Application.get_env(:site, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: Site.PubSub},
BoardWiseWeb.Telemetry,
BoardWise.Repo,
{DNSCluster, query: Application.get_env(:boardwise, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: BoardWise.PubSub},
# Start the Finch HTTP client for sending emails
{Finch, name: Site.Finch},
# Start a worker by calling: Site.Worker.start_link(arg)
# {Site.Worker, arg},
{Finch, name: BoardWise.Finch},
# Start a worker by calling: BoardWise.Worker.start_link(arg)
# {BoardWise.Worker, arg},
# Start to serve requests, typically the last entry
SiteWeb.Endpoint
BoardWiseWeb.Endpoint
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Site.Supervisor]
opts = [strategy: :one_for_one, name: BoardWise.Supervisor]
Supervisor.start_link(children, opts)
end
@ -30,7 +30,7 @@ defmodule Site.Application do
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
SiteWeb.Endpoint.config_change(changed, removed)
BoardWiseWeb.Endpoint.config_change(changed, removed)
:ok
end
end

3
lib/boardwise/mailer.ex Normal file
View File

@ -0,0 +1,3 @@
defmodule BoardWise.Mailer do
use Swoosh.Mailer, otp_app: :boardwise
end

View File

@ -1,5 +1,5 @@
defmodule Site.Repo do
defmodule BoardWise.Repo do
use Ecto.Repo,
otp_app: :site,
otp_app: :boardwise,
adapter: Ecto.Adapters.Postgres
end

View File

@ -1,12 +1,12 @@
defmodule SiteWeb do
defmodule BoardWiseWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, components, channels, and so on.
This can be used in your application as:
use SiteWeb, :controller
use SiteWeb, :html
use BoardWiseWeb, :controller
use BoardWiseWeb, :html
The definitions below will be executed for every controller,
component, etc, so keep them short and clean, focused
@ -40,10 +40,10 @@ defmodule SiteWeb do
quote do
use Phoenix.Controller,
formats: [:html, :json],
layouts: [html: SiteWeb.Layouts]
layouts: [html: BoardWiseWeb.Layouts]
import Plug.Conn
import SiteWeb.Gettext
import BoardWiseWeb.Gettext
unquote(verified_routes())
end
@ -52,7 +52,7 @@ defmodule SiteWeb do
def live_view do
quote do
use Phoenix.LiveView,
layout: {SiteWeb.Layouts, :app}
layout: {BoardWiseWeb.Layouts, :app}
unquote(html_helpers())
end
@ -84,8 +84,8 @@ defmodule SiteWeb do
# HTML escaping functionality
import Phoenix.HTML
# Core UI components and translation
import SiteWeb.CoreComponents
import SiteWeb.Gettext
import BoardWiseWeb.CoreComponents
import BoardWiseWeb.Gettext
# Shortcut for generating JS commands
alias Phoenix.LiveView.JS
@ -98,9 +98,9 @@ defmodule SiteWeb do
def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: SiteWeb.Endpoint,
router: SiteWeb.Router,
statics: SiteWeb.static_paths()
endpoint: BoardWiseWeb.Endpoint,
router: BoardWiseWeb.Router,
statics: BoardWiseWeb.static_paths()
end
end

View File

@ -1,4 +1,4 @@
defmodule SiteWeb.CoreComponents do
defmodule BoardWiseWeb.CoreComponents do
@moduledoc """
Provides core UI components.
@ -17,7 +17,7 @@ defmodule SiteWeb.CoreComponents do
use Phoenix.Component
alias Phoenix.LiveView.JS
import SiteWeb.Gettext
import BoardWiseWeb.Gettext
@doc """
Renders a modal.
@ -659,9 +659,9 @@ defmodule SiteWeb.CoreComponents do
# with our gettext backend as first argument. Translations are
# available in the errors.po file (as we use the "errors" domain).
if count = opts[:count] do
Gettext.dngettext(SiteWeb.Gettext, "errors", msg, msg, count, opts)
Gettext.dngettext(BoardWiseWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(SiteWeb.Gettext, "errors", msg, opts)
Gettext.dgettext(BoardWiseWeb.Gettext, "errors", msg, opts)
end
end

View File

@ -0,0 +1,5 @@
defmodule BoardWiseWeb.Layouts do
use BoardWiseWeb, :html
embed_templates "layouts/*"
end

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content={get_csrf_token()} />
<.live_title suffix=" · Phoenix Framework">
<%= assigns[:page_title] || "Site" %>
<%= assigns[:page_title] || "BoardWise" %>
</.live_title>
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>

View File

@ -1,12 +1,12 @@
defmodule SiteWeb.ErrorHTML do
use SiteWeb, :html
defmodule BoardWiseWeb.ErrorHTML do
use BoardWiseWeb, :html
# If you want to customize your error pages,
# uncomment the embed_templates/1 call below
# and add pages to the error directory:
#
# * lib/site_web/controllers/error_html/404.html.heex
# * lib/site_web/controllers/error_html/500.html.heex
# * lib/boardwise_web/controllers/error_html/404.html.heex
# * lib/boardwise_web/controllers/error_html/500.html.heex
#
# embed_templates "error_html/*"

View File

@ -1,4 +1,4 @@
defmodule SiteWeb.ErrorJSON do
defmodule BoardWiseWeb.ErrorJSON do
# If you want to customize a particular status code,
# you may add your own clauses, such as:
#

View File

@ -1,5 +1,5 @@
defmodule SiteWeb.PageController do
use SiteWeb, :controller
defmodule BoardWiseWeb.PageController do
use BoardWiseWeb, :controller
def home(conn, _params) do
# The home page is often custom made,

View File

@ -0,0 +1,5 @@
defmodule BoardWiseWeb.PageHTML do
use BoardWiseWeb, :html
embed_templates "page_html/*"
end

View File

@ -1,13 +1,13 @@
defmodule SiteWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :site
defmodule BoardWiseWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :boardwise
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_site_key",
signing_salt: "ywosTGeI",
key: "_boardwise_key",
signing_salt: "YH8oartu",
same_site: "Lax"
]
@ -19,9 +19,9 @@ defmodule SiteWeb.Endpoint do
# when deploying your static files in production.
plug Plug.Static,
at: "/",
from: :site,
from: :boardwise,
gzip: false,
only: SiteWeb.static_paths()
only: BoardWiseWeb.static_paths()
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
@ -29,7 +29,7 @@ defmodule SiteWeb.Endpoint do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :site
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :boardwise
end
plug Phoenix.LiveDashboard.RequestLogger,
@ -47,5 +47,5 @@ defmodule SiteWeb.Endpoint do
plug Plug.MethodOverride
plug Plug.Head
plug Plug.Session, @session_options
plug SiteWeb.Router
plug BoardWiseWeb.Router
end

View File

@ -1,11 +1,11 @@
defmodule SiteWeb.Gettext do
defmodule BoardWiseWeb.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import SiteWeb.Gettext
import BoardWiseWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
@ -20,5 +20,5 @@ defmodule SiteWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :site
use Gettext, otp_app: :boardwise
end

View File

@ -1,11 +1,11 @@
defmodule SiteWeb.Router do
use SiteWeb, :router
defmodule BoardWiseWeb.Router do
use BoardWiseWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {SiteWeb.Layouts, :root}
plug :put_root_layout, html: {BoardWiseWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
@ -14,19 +14,19 @@ defmodule SiteWeb.Router do
plug :accepts, ["json"]
end
scope "/", SiteWeb do
scope "/", BoardWiseWeb do
pipe_through :browser
get "/", PageController, :home
end
# Other scopes may use custom stacks.
# scope "/api", SiteWeb do
# scope "/api", BoardWiseWeb do
# pipe_through :api
# end
# Enable LiveDashboard and Swoosh mailbox preview in development
if Application.compile_env(:site, :dev_routes) do
if Application.compile_env(:boardwise, :dev_routes) do
# If you want to use the LiveDashboard in production, you should put
# it behind authentication and allow only admins to access it.
# If your application does not have an admins-only section yet,
@ -37,7 +37,7 @@ defmodule SiteWeb.Router do
scope "/dev" do
pipe_through :browser
live_dashboard "/dashboard", metrics: SiteWeb.Telemetry
live_dashboard "/dashboard", metrics: BoardWiseWeb.Telemetry
forward "/mailbox", Plug.Swoosh.MailboxPreview
end
end

View File

@ -1,4 +1,4 @@
defmodule SiteWeb.Telemetry do
defmodule BoardWiseWeb.Telemetry do
use Supervisor
import Telemetry.Metrics
@ -52,23 +52,23 @@ defmodule SiteWeb.Telemetry do
),
# Database Metrics
summary("site.repo.query.total_time",
summary("boardwise.repo.query.total_time",
unit: {:native, :millisecond},
description: "The sum of the other measurements"
),
summary("site.repo.query.decode_time",
summary("boardwise.repo.query.decode_time",
unit: {:native, :millisecond},
description: "The time spent decoding the data received from the database"
),
summary("site.repo.query.query_time",
summary("boardwise.repo.query.query_time",
unit: {:native, :millisecond},
description: "The time spent executing the query"
),
summary("site.repo.query.queue_time",
summary("boardwise.repo.query.queue_time",
unit: {:native, :millisecond},
description: "The time spent waiting for a database connection"
),
summary("site.repo.query.idle_time",
summary("boardwise.repo.query.idle_time",
unit: {:native, :millisecond},
description:
"The time the connection spent waiting before being checked out for the query"
@ -86,7 +86,7 @@ defmodule SiteWeb.Telemetry do
[
# A module, function and arguments to be invoked periodically.
# This function must call :telemetry.execute/3 and a metric must be added above.
# {SiteWeb, :count_users, []}
# {BoardWiseWeb, :count_users, []}
]
end
end

View File

@ -1,3 +0,0 @@
defmodule Site.Mailer do
use Swoosh.Mailer, otp_app: :site
end

View File

@ -1,5 +0,0 @@
defmodule SiteWeb.Layouts do
use SiteWeb, :html
embed_templates "layouts/*"
end

View File

@ -1,5 +0,0 @@
defmodule SiteWeb.PageHTML do
use SiteWeb, :html
embed_templates "page_html/*"
end

View File

@ -1,9 +1,9 @@
defmodule Site.MixProject do
defmodule BoardWise.MixProject do
use Mix.Project
def project do
[
app: :site,
app: :boardwise,
version: "0.1.0",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
@ -18,7 +18,7 @@ defmodule Site.MixProject do
# Type `mix help compile.app` for more information.
def application do
[
mod: {Site.Application, []},
mod: {BoardWise.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end

View File

@ -5,7 +5,7 @@
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Site.Repo.insert!(%Site.SomeSchema{})
# BoardWise.Repo.insert!(%BoardWise.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.

View File

@ -0,0 +1,14 @@
defmodule BoardWiseWeb.ErrorHTMLTest do
use BoardWiseWeb.ConnCase, async: true
# Bring render_to_string/4 for testing custom views
import Phoenix.Template
test "renders 404.html" do
assert render_to_string(BoardWiseWeb.ErrorHTML, "404", "html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(BoardWiseWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
end
end

View File

@ -0,0 +1,12 @@
defmodule BoardWiseWeb.ErrorJSONTest do
use BoardWiseWeb.ConnCase, async: true
test "renders 404" do
assert BoardWiseWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
end
test "renders 500" do
assert BoardWiseWeb.ErrorJSON.render("500.json", %{}) ==
%{errors: %{detail: "Internal Server Error"}}
end
end

View File

@ -1,5 +1,5 @@
defmodule SiteWeb.PageControllerTest do
use SiteWeb.ConnCase
defmodule BoardWiseWeb.PageControllerTest do
use BoardWiseWeb.ConnCase
test "GET /", %{conn: conn} do
conn = get(conn, ~p"/")

View File

@ -1,14 +0,0 @@
defmodule SiteWeb.ErrorHTMLTest do
use SiteWeb.ConnCase, async: true
# Bring render_to_string/4 for testing custom views
import Phoenix.Template
test "renders 404.html" do
assert render_to_string(SiteWeb.ErrorHTML, "404", "html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(SiteWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
end
end

View File

@ -1,12 +0,0 @@
defmodule SiteWeb.ErrorJSONTest do
use SiteWeb.ConnCase, async: true
test "renders 404" do
assert SiteWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
end
test "renders 500" do
assert SiteWeb.ErrorJSON.render("500.json", %{}) ==
%{errors: %{detail: "Internal Server Error"}}
end
end

View File

@ -1,4 +1,4 @@
defmodule SiteWeb.ConnCase do
defmodule BoardWiseWeb.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 SiteWeb.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 SiteWeb.ConnCase, async: true`, although
by setting `use BoardWiseWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
"""
@ -20,19 +20,19 @@ defmodule SiteWeb.ConnCase do
using do
quote do
# The default endpoint for testing
@endpoint SiteWeb.Endpoint
@endpoint BoardWiseWeb.Endpoint
use SiteWeb, :verified_routes
use BoardWiseWeb, :verified_routes
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import SiteWeb.ConnCase
import BoardWiseWeb.ConnCase
end
end
setup tags do
Site.DataCase.setup_sandbox(tags)
BoardWise.DataCase.setup_sandbox(tags)
{:ok, conn: Phoenix.ConnTest.build_conn()}
end
end

View File

@ -1,4 +1,4 @@
defmodule Site.DataCase do
defmodule BoardWise.DataCase do
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
@ -10,7 +10,7 @@ defmodule Site.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 Site.DataCase, async: true`, although
by setting `use BoardWise.DataCase, async: true`, although
this option is not recommended for other databases.
"""
@ -18,17 +18,17 @@ defmodule Site.DataCase do
using do
quote do
alias Site.Repo
alias BoardWise.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
import Site.DataCase
import BoardWise.DataCase
end
end
setup tags do
Site.DataCase.setup_sandbox(tags)
BoardWise.DataCase.setup_sandbox(tags)
:ok
end
@ -36,7 +36,7 @@ defmodule Site.DataCase do
Sets up the sandbox based on the test tags.
"""
def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Site.Repo, shared: not tags[:async])
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(BoardWise.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
end

View File

@ -1,2 +1,2 @@
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Site.Repo, :manual)
Ecto.Adapters.SQL.Sandbox.mode(BoardWise.Repo, :manual)