diff --git a/.gitignore b/.gitignore
index 84bdfa8..6401a42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,7 +24,7 @@ erl_crash.dump
*.ez
# Ignore package tarball (built via "mix hex.build").
-real_estate-*.tar
+bones73k-*.tar
# If NPM crashes, it generates a log, let's ignore it too.
npm-debug.log
diff --git a/README.md b/README.md
index ef41957..1f40285 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# RealEstate
+# Bones73k
See full article [here](https://www.leanpanda.com/blog/authentication-and-authorisation-in-phoenix-liveview/).
diff --git a/config/config.exs b/config/config.exs
index 81b8cc2..fb504b9 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -7,15 +7,15 @@
# General application configuration
use Mix.Config
-config :real_estate,
- ecto_repos: [RealEstate.Repo]
+config :bones73k,
+ ecto_repos: [Bones73k.Repo]
# Configures the endpoint
-config :real_estate, RealEstateWeb.Endpoint,
+config :bones73k, Bones73kWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "LdIQmzV5UCWSbB2SdiWFHLgxYNObKq9Za/VyguoILxfOAMDb5IsptKCKtXTRn+Tf",
- render_errors: [view: RealEstateWeb.ErrorView, accepts: ~w(html json), layout: false],
- pubsub_server: RealEstate.PubSub,
+ render_errors: [view: Bones73kWeb.ErrorView, accepts: ~w(html json), layout: false],
+ pubsub_server: Bones73k.PubSub,
live_view: [signing_salt: "2D4GC4ac"]
# Configures Elixir's Logger
diff --git a/config/prod.exs b/config/prod.exs
index 84f7412..5a39627 100644
--- a/config/prod.exs
+++ b/config/prod.exs
@@ -9,7 +9,7 @@ use Mix.Config
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
-config :real_estate, RealEstateWeb.Endpoint,
+config :bones73k, Bones73kWeb.Endpoint,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
@@ -21,7 +21,7 @@ config :logger, level: :info
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
-# config :real_estate, RealEstateWeb.Endpoint,
+# config :bones73k, Bones73kWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [
@@ -45,7 +45,7 @@ config :logger, level: :info
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
-# config :real_estate, RealEstateWeb.Endpoint,
+# config :bones73k, Bones73kWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
diff --git a/lib/real_estate.ex b/lib/bones73k.ex
similarity index 68%
rename from lib/real_estate.ex
rename to lib/bones73k.ex
index d02aa30..01655ac 100644
--- a/lib/real_estate.ex
+++ b/lib/bones73k.ex
@@ -1,6 +1,6 @@
-defmodule RealEstate do
+defmodule Bones73k do
@moduledoc """
- RealEstate keeps the contexts that define your domain
+ Bones73k keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless
diff --git a/lib/real_estate/accounts.ex b/lib/bones73k/accounts.ex
similarity index 98%
rename from lib/real_estate/accounts.ex
rename to lib/bones73k/accounts.ex
index 1604f33..da69fef 100644
--- a/lib/real_estate/accounts.ex
+++ b/lib/bones73k/accounts.ex
@@ -1,12 +1,12 @@
-defmodule RealEstate.Accounts do
+defmodule Bones73k.Accounts do
@moduledoc """
The Accounts context.
"""
import Ecto.Query, warn: false
- alias RealEstate.Repo
- alias RealEstate.Accounts.{User, UserToken, UserNotifier}
- alias RealEstateWeb.UserAuth
+ alias Bones73k.Repo
+ alias Bones73k.Accounts.{User, UserToken, UserNotifier}
+ alias Bones73kWeb.UserAuth
## Database getters
@@ -103,7 +103,7 @@ defmodule RealEstate.Accounts do
Repo.delete_all(UserToken.user_and_contexts_query(user, :all))
# Broadcast to all liveviews to immediately disconnect the user
- RealEstateWeb.Endpoint.broadcast_from(
+ Bones73kWeb.Endpoint.broadcast_from(
self(),
UserAuth.pubsub_topic(),
"logout_user",
diff --git a/lib/real_estate/accounts/user.ex b/lib/bones73k/accounts/user.ex
similarity index 95%
rename from lib/real_estate/accounts/user.ex
rename to lib/bones73k/accounts/user.ex
index 2a4e286..8921f11 100644
--- a/lib/real_estate/accounts/user.ex
+++ b/lib/bones73k/accounts/user.ex
@@ -1,4 +1,4 @@
-defmodule RealEstate.Accounts.User do
+defmodule Bones73k.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
import EctoEnum
@@ -48,7 +48,7 @@ defmodule RealEstate.Accounts.User do
|> validate_required([:email])
|> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces")
|> validate_length(:email, max: 160)
- |> unsafe_validate_unique(:email, RealEstate.Repo)
+ |> unsafe_validate_unique(:email, Bones73k.Repo)
|> unique_constraint(:email)
end
@@ -114,7 +114,7 @@ defmodule RealEstate.Accounts.User do
If there is no user or the user doesn't have a password, we call
`Bcrypt.no_user_verify/0` to avoid timing attacks.
"""
- def valid_password?(%RealEstate.Accounts.User{hashed_password: hashed_password}, password)
+ def valid_password?(%Bones73k.Accounts.User{hashed_password: hashed_password}, password)
when is_binary(hashed_password) and byte_size(password) > 0 do
Bcrypt.verify_pass(password, hashed_password)
end
diff --git a/lib/real_estate/accounts/user_notifier.ex b/lib/bones73k/accounts/user_notifier.ex
similarity index 97%
rename from lib/real_estate/accounts/user_notifier.ex
rename to lib/bones73k/accounts/user_notifier.ex
index ad85ee8..928d275 100644
--- a/lib/real_estate/accounts/user_notifier.ex
+++ b/lib/bones73k/accounts/user_notifier.ex
@@ -1,4 +1,4 @@
-defmodule RealEstate.Accounts.UserNotifier do
+defmodule Bones73k.Accounts.UserNotifier do
# For simplicity, this module simply logs messages to the terminal.
# You should replace it by a proper email or notification tool, such as:
#
diff --git a/lib/real_estate/accounts/user_token.ex b/lib/bones73k/accounts/user_token.ex
similarity index 88%
rename from lib/real_estate/accounts/user_token.ex
rename to lib/bones73k/accounts/user_token.ex
index c9ae454..ba3911e 100644
--- a/lib/real_estate/accounts/user_token.ex
+++ b/lib/bones73k/accounts/user_token.ex
@@ -1,4 +1,4 @@
-defmodule RealEstate.Accounts.UserToken do
+defmodule Bones73k.Accounts.UserToken do
use Ecto.Schema
import Ecto.Query
@@ -16,7 +16,7 @@ defmodule RealEstate.Accounts.UserToken do
field :token, :binary
field :context, :string
field :sent_to, :string
- belongs_to :user, RealEstate.Accounts.User
+ belongs_to :user, Bones73k.Accounts.User
timestamps(updated_at: false)
end
@@ -28,7 +28,7 @@ defmodule RealEstate.Accounts.UserToken do
"""
def build_session_token(user) do
token = :crypto.strong_rand_bytes(@rand_size)
- {token, %RealEstate.Accounts.UserToken{token: token, context: "session", user_id: user.id}}
+ {token, %Bones73k.Accounts.UserToken{token: token, context: "session", user_id: user.id}}
end
@doc """
@@ -63,7 +63,7 @@ defmodule RealEstate.Accounts.UserToken do
hashed_token = :crypto.hash(@hash_algorithm, token)
{Base.url_encode64(token, padding: false),
- %RealEstate.Accounts.UserToken{
+ %Bones73k.Accounts.UserToken{
token: hashed_token,
context: context,
sent_to: sent_to,
@@ -123,17 +123,17 @@ defmodule RealEstate.Accounts.UserToken do
Returns the given token with the given context.
"""
def token_and_context_query(token, context) do
- from RealEstate.Accounts.UserToken, where: [token: ^token, context: ^context]
+ from Bones73k.Accounts.UserToken, where: [token: ^token, context: ^context]
end
@doc """
Gets all tokens for the given user for the given contexts.
"""
def user_and_contexts_query(user, :all) do
- from t in RealEstate.Accounts.UserToken, where: t.user_id == ^user.id
+ from t in Bones73k.Accounts.UserToken, where: t.user_id == ^user.id
end
def user_and_contexts_query(user, [_ | _] = contexts) do
- from t in RealEstate.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts
+ from t in Bones73k.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts
end
end
diff --git a/lib/real_estate/application.ex b/lib/bones73k/application.ex
similarity index 62%
rename from lib/real_estate/application.ex
rename to lib/bones73k/application.ex
index a311612..ea0a70b 100644
--- a/lib/real_estate/application.ex
+++ b/lib/bones73k/application.ex
@@ -1,4 +1,4 @@
-defmodule RealEstate.Application do
+defmodule Bones73k.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
@@ -8,27 +8,27 @@ defmodule RealEstate.Application do
def start(_type, _args) do
children = [
# Start the Ecto repository
- RealEstate.Repo,
+ Bones73k.Repo,
# Start the Telemetry supervisor
- RealEstateWeb.Telemetry,
+ Bones73kWeb.Telemetry,
# Start the PubSub system
- {Phoenix.PubSub, name: RealEstate.PubSub},
+ {Phoenix.PubSub, name: Bones73k.PubSub},
# Start the Endpoint (http/https)
- RealEstateWeb.Endpoint
- # Start a worker by calling: RealEstate.Worker.start_link(arg)
- # {RealEstate.Worker, arg}
+ Bones73kWeb.Endpoint
+ # Start a worker by calling: Bones73k.Worker.start_link(arg)
+ # {Bones73k.Worker, arg}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
- opts = [strategy: :one_for_one, name: RealEstate.Supervisor]
+ opts = [strategy: :one_for_one, name: Bones73k.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
- RealEstateWeb.Endpoint.config_change(changed, removed)
+ Bones73kWeb.Endpoint.config_change(changed, removed)
:ok
end
end
diff --git a/lib/real_estate/properties.ex b/lib/bones73k/properties.ex
similarity index 94%
rename from lib/real_estate/properties.ex
rename to lib/bones73k/properties.ex
index 5116d08..6b58584 100644
--- a/lib/real_estate/properties.ex
+++ b/lib/bones73k/properties.ex
@@ -1,12 +1,12 @@
-defmodule RealEstate.Properties do
+defmodule Bones73k.Properties do
@moduledoc """
The Properties context.
"""
import Ecto.Query, warn: false
- alias RealEstate.Repo
+ alias Bones73k.Repo
- alias RealEstate.Properties.Property
+ alias Bones73k.Properties.Property
@doc """
Returns the list of properties.
diff --git a/lib/real_estate/properties/property.ex b/lib/bones73k/properties/property.ex
similarity index 92%
rename from lib/real_estate/properties/property.ex
rename to lib/bones73k/properties/property.ex
index 9be0984..6293542 100644
--- a/lib/real_estate/properties/property.ex
+++ b/lib/bones73k/properties/property.ex
@@ -1,4 +1,4 @@
-defmodule RealEstate.Properties.Property do
+defmodule Bones73k.Properties.Property do
use Ecto.Schema
import Ecto.Changeset
diff --git a/lib/real_estate/repo.ex b/lib/bones73k/repo.ex
similarity index 50%
rename from lib/real_estate/repo.ex
rename to lib/bones73k/repo.ex
index 7eca83c..788fb53 100644
--- a/lib/real_estate/repo.ex
+++ b/lib/bones73k/repo.ex
@@ -1,5 +1,5 @@
-defmodule RealEstate.Repo do
+defmodule Bones73k.Repo do
use Ecto.Repo,
- otp_app: :real_estate,
+ otp_app: :bones73k,
adapter: Ecto.Adapters.Postgres
end
diff --git a/lib/real_estate_web.ex b/lib/bones73k_web.ex
similarity index 78%
rename from lib/real_estate_web.ex
rename to lib/bones73k_web.ex
index e671b17..6b3f2d4 100644
--- a/lib/real_estate_web.ex
+++ b/lib/bones73k_web.ex
@@ -1,12 +1,12 @@
-defmodule RealEstateWeb do
+defmodule Bones73kWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
- use RealEstateWeb, :controller
- use RealEstateWeb, :view
+ use Bones73kWeb, :controller
+ use Bones73kWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
@@ -19,19 +19,19 @@ defmodule RealEstateWeb do
def controller do
quote do
- use Phoenix.Controller, namespace: RealEstateWeb
+ use Phoenix.Controller, namespace: Bones73kWeb
import Plug.Conn
- import RealEstateWeb.Gettext
- alias RealEstateWeb.Router.Helpers, as: Routes
+ import Bones73kWeb.Gettext
+ alias Bones73kWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
- root: "lib/real_estate_web/templates",
- namespace: RealEstateWeb
+ root: "lib/bones73k_web/templates",
+ namespace: Bones73kWeb
# Import convenience functions from controllers
import Phoenix.Controller,
@@ -45,12 +45,12 @@ defmodule RealEstateWeb do
def live_view do
quote do
use Phoenix.LiveView,
- layout: {RealEstateWeb.LayoutView, "live.html"}
+ layout: {Bones73kWeb.LayoutView, "live.html"}
unquote(view_helpers())
- import RealEstateWeb.LiveHelpers
+ import Bones73kWeb.LiveHelpers
- alias RealEstate.Accounts.User
+ alias Bones73k.Accounts.User
@impl true
def handle_info(%{event: "logout_user", payload: %{user: %User{id: id}}}, socket) do
@@ -86,7 +86,7 @@ defmodule RealEstateWeb do
def channel do
quote do
use Phoenix.Channel
- import RealEstateWeb.Gettext
+ import Bones73kWeb.Gettext
end
end
@@ -101,9 +101,9 @@ defmodule RealEstateWeb do
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
- import RealEstateWeb.ErrorHelpers
- import RealEstateWeb.Gettext
- alias RealEstateWeb.Router.Helpers, as: Routes
+ import Bones73kWeb.ErrorHelpers
+ import Bones73kWeb.Gettext
+ alias Bones73kWeb.Router.Helpers, as: Routes
end
end
diff --git a/lib/real_estate_web/channels/user_socket.ex b/lib/bones73k_web/channels/user_socket.ex
similarity index 84%
rename from lib/real_estate_web/channels/user_socket.ex
rename to lib/bones73k_web/channels/user_socket.ex
index 9fa80fc..c9fbafa 100644
--- a/lib/real_estate_web/channels/user_socket.ex
+++ b/lib/bones73k_web/channels/user_socket.ex
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.UserSocket do
+defmodule Bones73kWeb.UserSocket do
use Phoenix.Socket
## Channels
- # channel "room:*", RealEstateWeb.RoomChannel
+ # channel "room:*", Bones73kWeb.RoomChannel
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
@@ -27,7 +27,7 @@ defmodule RealEstateWeb.UserSocket do
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
- # RealEstateWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
+ # Bones73kWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
@impl true
diff --git a/lib/real_estate_web/controllers/user_auth.ex b/lib/bones73k_web/controllers/user_auth.ex
similarity index 96%
rename from lib/real_estate_web/controllers/user_auth.ex
rename to lib/bones73k_web/controllers/user_auth.ex
index 8664c4e..cd0de8e 100644
--- a/lib/real_estate_web/controllers/user_auth.ex
+++ b/lib/bones73k_web/controllers/user_auth.ex
@@ -1,9 +1,9 @@
-defmodule RealEstateWeb.UserAuth do
+defmodule Bones73kWeb.UserAuth do
import Plug.Conn
import Phoenix.Controller
- alias RealEstate.Accounts
- alias RealEstateWeb.Router.Helpers, as: Routes
+ alias Bones73k.Accounts
+ alias Bones73kWeb.Router.Helpers, as: Routes
@pubsub_topic "user_updates"
@@ -77,7 +77,7 @@ defmodule RealEstateWeb.UserAuth do
user_token && Accounts.delete_session_token(user_token)
if live_socket_id = get_session(conn, :live_socket_id) do
- RealEstateWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{})
+ Bones73kWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{})
end
conn
diff --git a/lib/real_estate_web/controllers/user_confirmation_controller.ex b/lib/bones73k_web/controllers/user_confirmation_controller.ex
similarity index 90%
rename from lib/real_estate_web/controllers/user_confirmation_controller.ex
rename to lib/bones73k_web/controllers/user_confirmation_controller.ex
index 9e42b43..c677497 100644
--- a/lib/real_estate_web/controllers/user_confirmation_controller.ex
+++ b/lib/bones73k_web/controllers/user_confirmation_controller.ex
@@ -1,7 +1,7 @@
-defmodule RealEstateWeb.UserConfirmationController do
- use RealEstateWeb, :controller
+defmodule Bones73kWeb.UserConfirmationController do
+ use Bones73kWeb, :controller
- alias RealEstate.Accounts
+ alias Bones73k.Accounts
def new(conn, _params) do
render(conn, "new.html")
diff --git a/lib/real_estate_web/controllers/user_registration_controller.ex b/lib/bones73k_web/controllers/user_registration_controller.ex
similarity index 78%
rename from lib/real_estate_web/controllers/user_registration_controller.ex
rename to lib/bones73k_web/controllers/user_registration_controller.ex
index 0d42f1f..1809103 100644
--- a/lib/real_estate_web/controllers/user_registration_controller.ex
+++ b/lib/bones73k_web/controllers/user_registration_controller.ex
@@ -1,9 +1,9 @@
-defmodule RealEstateWeb.UserRegistrationController do
- use RealEstateWeb, :controller
+defmodule Bones73kWeb.UserRegistrationController do
+ use Bones73kWeb, :controller
- alias RealEstate.Accounts
- alias RealEstate.Accounts.User
- alias RealEstateWeb.UserAuth
+ alias Bones73k.Accounts
+ alias Bones73k.Accounts.User
+ alias Bones73kWeb.UserAuth
def new(conn, _params) do
changeset = Accounts.change_user_registration(%User{})
diff --git a/lib/real_estate_web/controllers/user_reset_password_controller.ex b/lib/bones73k_web/controllers/user_reset_password_controller.ex
similarity index 89%
rename from lib/real_estate_web/controllers/user_reset_password_controller.ex
rename to lib/bones73k_web/controllers/user_reset_password_controller.ex
index 21a35e0..3ff6dcd 100644
--- a/lib/real_estate_web/controllers/user_reset_password_controller.ex
+++ b/lib/bones73k_web/controllers/user_reset_password_controller.ex
@@ -1,9 +1,9 @@
-defmodule RealEstateWeb.UserResetPasswordController do
- use RealEstateWeb, :controller
+defmodule Bones73kWeb.UserResetPasswordController do
+ use Bones73kWeb, :controller
- alias RealEstate.Accounts
+ alias Bones73k.Accounts
- plug :get_user_by_reset_password_token when action in [:edit, :update]
+ plug(:get_user_by_reset_password_token when action in [:edit, :update])
def new(conn, _params) do
render(conn, "new.html")
diff --git a/lib/real_estate_web/controllers/user_session_controller.ex b/lib/bones73k_web/controllers/user_session_controller.ex
similarity index 84%
rename from lib/real_estate_web/controllers/user_session_controller.ex
rename to lib/bones73k_web/controllers/user_session_controller.ex
index 6817be7..5c9f68d 100644
--- a/lib/real_estate_web/controllers/user_session_controller.ex
+++ b/lib/bones73k_web/controllers/user_session_controller.ex
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.UserSessionController do
- use RealEstateWeb, :controller
+defmodule Bones73kWeb.UserSessionController do
+ use Bones73kWeb, :controller
- alias RealEstate.Accounts
- alias RealEstateWeb.UserAuth
+ alias Bones73k.Accounts
+ alias Bones73kWeb.UserAuth
def new(conn, _params) do
render(conn, "new.html", error_message: nil)
diff --git a/lib/real_estate_web/controllers/user_settings_controller.ex b/lib/bones73k_web/controllers/user_settings_controller.ex
similarity index 91%
rename from lib/real_estate_web/controllers/user_settings_controller.ex
rename to lib/bones73k_web/controllers/user_settings_controller.ex
index be79d65..a2e9b7e 100644
--- a/lib/real_estate_web/controllers/user_settings_controller.ex
+++ b/lib/bones73k_web/controllers/user_settings_controller.ex
@@ -1,10 +1,10 @@
-defmodule RealEstateWeb.UserSettingsController do
- use RealEstateWeb, :controller
+defmodule Bones73kWeb.UserSettingsController do
+ use Bones73kWeb, :controller
- alias RealEstate.Accounts
- alias RealEstateWeb.UserAuth
+ alias Bones73k.Accounts
+ alias Bones73kWeb.UserAuth
- plug :assign_email_and_password_changesets
+ plug(:assign_email_and_password_changesets)
def edit(conn, _params) do
render(conn, "edit.html")
diff --git a/lib/real_estate_web/endpoint.ex b/lib/bones73k_web/endpoint.ex
similarity index 54%
rename from lib/real_estate_web/endpoint.ex
rename to lib/bones73k_web/endpoint.ex
index 0c34ef7..d20b994 100644
--- a/lib/real_estate_web/endpoint.ex
+++ b/lib/bones73k_web/endpoint.ex
@@ -1,54 +1,58 @@
-defmodule RealEstateWeb.Endpoint do
- use Phoenix.Endpoint, otp_app: :real_estate
+defmodule Bones73kWeb.Endpoint do
+ use Phoenix.Endpoint, otp_app: :bones73k
# 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: "_real_estate_key",
+ key: "_bones73k_key",
signing_salt: "9CKxo0VJ"
]
- socket "/socket", RealEstateWeb.UserSocket,
+ socket("/socket", Bones73kWeb.UserSocket,
websocket: true,
longpoll: false
+ )
- socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]
+ socket("/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]])
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phx.digest
# when deploying your static files in production.
- plug Plug.Static,
+ plug(Plug.Static,
at: "/",
- from: :real_estate,
+ from: :bones73k,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
+ )
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
- socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
- plug Phoenix.LiveReloader
- plug Phoenix.CodeReloader
- plug Phoenix.Ecto.CheckRepoStatus, otp_app: :real_estate
+ socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
+ plug(Phoenix.LiveReloader)
+ plug(Phoenix.CodeReloader)
+ plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :bones73k)
end
- plug Phoenix.LiveDashboard.RequestLogger,
+ plug(Phoenix.LiveDashboard.RequestLogger,
param_key: "request_logger",
cookie_key: "request_logger"
+ )
- plug Plug.RequestId
- plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
+ plug(Plug.RequestId)
+ plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
- plug Plug.Parsers,
+ plug(Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
+ )
- plug Plug.MethodOverride
- plug Plug.Head
- plug Plug.Session, @session_options
- plug RealEstateWeb.Router
+ plug(Plug.MethodOverride)
+ plug(Plug.Head)
+ plug(Plug.Session, @session_options)
+ plug(Bones73kWeb.Router)
end
diff --git a/lib/real_estate_web/gettext.ex b/lib/bones73k_web/gettext.ex
similarity index 85%
rename from lib/real_estate_web/gettext.ex
rename to lib/bones73k_web/gettext.ex
index 3fc9bca..6d6d65b 100644
--- a/lib/real_estate_web/gettext.ex
+++ b/lib/bones73k_web/gettext.ex
@@ -1,11 +1,11 @@
-defmodule RealEstateWeb.Gettext do
+defmodule Bones73kWeb.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 RealEstateWeb.Gettext
+ import Bones73kWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
@@ -20,5 +20,5 @@ defmodule RealEstateWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
- use Gettext, otp_app: :real_estate
+ use Gettext, otp_app: :bones73k
end
diff --git a/lib/real_estate_web/live/admin_dashboard_live.ex b/lib/bones73k_web/live/admin_dashboard_live.ex
similarity index 78%
rename from lib/real_estate_web/live/admin_dashboard_live.ex
rename to lib/bones73k_web/live/admin_dashboard_live.ex
index 8b1912f..9010799 100644
--- a/lib/real_estate_web/live/admin_dashboard_live.ex
+++ b/lib/bones73k_web/live/admin_dashboard_live.ex
@@ -1,5 +1,5 @@
-defmodule RealEstateWeb.AdminDashboardLive do
- use RealEstateWeb, :live_view
+defmodule Bones73kWeb.AdminDashboardLive do
+ use Bones73kWeb, :live_view
@impl true
def mount(_params, session, socket) do
diff --git a/lib/real_estate_web/live/live_helpers.ex b/lib/bones73k_web/live/live_helpers.ex
similarity index 71%
rename from lib/real_estate_web/live/live_helpers.ex
rename to lib/bones73k_web/live/live_helpers.ex
index 2939122..01cf17a 100644
--- a/lib/real_estate_web/live/live_helpers.ex
+++ b/lib/bones73k_web/live/live_helpers.ex
@@ -1,20 +1,20 @@
-defmodule RealEstateWeb.LiveHelpers do
+defmodule Bones73kWeb.LiveHelpers do
import Phoenix.LiveView
- alias RealEstate.Accounts
- alias RealEstate.Accounts.User
- alias RealEstateWeb.Router.Helpers, as: Routes
- alias RealEstateWeb.UserAuth
+ alias Bones73k.Accounts
+ alias Bones73k.Accounts.User
+ alias Bones73kWeb.Router.Helpers, as: Routes
+ alias Bones73kWeb.UserAuth
import Phoenix.LiveView.Helpers
@doc """
- Renders a component inside the `RealEstateWeb.ModalComponent` component.
+ Renders a component inside the `Bones73kWeb.ModalComponent` component.
The rendered modal receives a `:return_to` option to properly update
the URL when the modal is closed.
## Examples
- <%= live_modal @socket, RealEstateWeb.PropertyLive.FormComponent,
+ <%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
id: @property.id || :new,
action: @live_action,
property: @property,
@@ -23,11 +23,11 @@ defmodule RealEstateWeb.LiveHelpers do
def live_modal(socket, component, opts) do
path = Keyword.fetch!(opts, :return_to)
modal_opts = [id: :modal, return_to: path, component: component, opts: opts]
- live_component(socket, RealEstateWeb.ModalComponent, modal_opts)
+ live_component(socket, Bones73kWeb.ModalComponent, modal_opts)
end
def assign_defaults(session, socket) do
- RealEstateWeb.Endpoint.subscribe(UserAuth.pubsub_topic())
+ Bones73kWeb.Endpoint.subscribe(UserAuth.pubsub_topic())
socket =
assign_new(socket, :current_user, fn ->
diff --git a/lib/real_estate_web/live/modal_component.ex b/lib/bones73k_web/live/modal_component.ex
similarity index 88%
rename from lib/real_estate_web/live/modal_component.ex
rename to lib/bones73k_web/live/modal_component.ex
index 1f10e59..403245f 100644
--- a/lib/real_estate_web/live/modal_component.ex
+++ b/lib/bones73k_web/live/modal_component.ex
@@ -1,5 +1,5 @@
-defmodule RealEstateWeb.ModalComponent do
- use RealEstateWeb, :live_component
+defmodule Bones73kWeb.ModalComponent do
+ use Bones73kWeb, :live_component
@impl true
def render(assigns) do
diff --git a/lib/real_estate_web/live/page_live.ex b/lib/bones73k_web/live/page_live.ex
similarity index 88%
rename from lib/real_estate_web/live/page_live.ex
rename to lib/bones73k_web/live/page_live.ex
index 681915e..59463e2 100644
--- a/lib/real_estate_web/live/page_live.ex
+++ b/lib/bones73k_web/live/page_live.ex
@@ -1,5 +1,5 @@
-defmodule RealEstateWeb.PageLive do
- use RealEstateWeb, :live_view
+defmodule Bones73kWeb.PageLive do
+ use Bones73kWeb, :live_view
@impl true
def mount(_params, session, socket) do
@@ -27,7 +27,7 @@ defmodule RealEstateWeb.PageLive do
end
defp search(query) do
- if not RealEstateWeb.Endpoint.config(:code_reloader) do
+ if not Bones73kWeb.Endpoint.config(:code_reloader) do
raise "action disabled when not in development"
end
diff --git a/lib/real_estate_web/live/page_live.html.leex b/lib/bones73k_web/live/page_live.html.leex
similarity index 100%
rename from lib/real_estate_web/live/page_live.html.leex
rename to lib/bones73k_web/live/page_live.html.leex
diff --git a/lib/real_estate_web/live/property_live/form_component.ex b/lib/bones73k_web/live/property_live/form_component.ex
similarity index 93%
rename from lib/real_estate_web/live/property_live/form_component.ex
rename to lib/bones73k_web/live/property_live/form_component.ex
index 0d8d314..00357b3 100644
--- a/lib/real_estate_web/live/property_live/form_component.ex
+++ b/lib/bones73k_web/live/property_live/form_component.ex
@@ -1,7 +1,7 @@
-defmodule RealEstateWeb.PropertyLive.FormComponent do
- use RealEstateWeb, :live_component
+defmodule Bones73kWeb.PropertyLive.FormComponent do
+ use Bones73kWeb, :live_component
- alias RealEstate.Properties
+ alias Bones73k.Properties
@impl true
def update(%{property: property} = assigns, socket) do
diff --git a/lib/real_estate_web/live/property_live/form_component.html.leex b/lib/bones73k_web/live/property_live/form_component.html.leex
similarity index 100%
rename from lib/real_estate_web/live/property_live/form_component.html.leex
rename to lib/bones73k_web/live/property_live/form_component.html.leex
diff --git a/lib/real_estate_web/live/property_live/index.ex b/lib/bones73k_web/live/property_live/index.ex
similarity index 88%
rename from lib/real_estate_web/live/property_live/index.ex
rename to lib/bones73k_web/live/property_live/index.ex
index 3214ab3..185083a 100644
--- a/lib/real_estate_web/live/property_live/index.ex
+++ b/lib/bones73k_web/live/property_live/index.ex
@@ -1,9 +1,9 @@
-defmodule RealEstateWeb.PropertyLive.Index do
- use RealEstateWeb, :live_view
+defmodule Bones73kWeb.PropertyLive.Index do
+ use Bones73kWeb, :live_view
- alias RealEstate.Properties
- alias RealEstate.Properties.Property
- alias RealEstateWeb.Roles
+ alias Bones73k.Properties
+ alias Bones73k.Properties.Property
+ alias Bones73kWeb.Roles
@impl true
def mount(_params, session, socket) do
@@ -51,7 +51,7 @@ defmodule RealEstateWeb.PropertyLive.Index do
current_user = socket.assigns.current_user
property = Properties.get_property!(id)
- if RealEstateWeb.Roles.can?(current_user, property, :delete) do
+ if Bones73kWeb.Roles.can?(current_user, property, :delete) do
property = Properties.get_property!(id)
{:ok, _} = Properties.delete_property(property)
diff --git a/lib/real_estate_web/live/property_live/index.html.leex b/lib/bones73k_web/live/property_live/index.html.leex
similarity index 95%
rename from lib/real_estate_web/live/property_live/index.html.leex
rename to lib/bones73k_web/live/property_live/index.html.leex
index 712efba..7089e67 100644
--- a/lib/real_estate_web/live/property_live/index.html.leex
+++ b/lib/bones73k_web/live/property_live/index.html.leex
@@ -1,7 +1,7 @@
Listing Properties
<%= if @live_action in [:new, :edit] do %>
- <%= live_modal @socket, RealEstateWeb.PropertyLive.FormComponent,
+ <%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
id: @property.id || :new,
title: @page_title,
action: @live_action,
diff --git a/lib/real_estate_web/live/property_live/show.ex b/lib/bones73k_web/live/property_live/show.ex
similarity index 84%
rename from lib/real_estate_web/live/property_live/show.ex
rename to lib/bones73k_web/live/property_live/show.ex
index 3893833..7fc8c01 100644
--- a/lib/real_estate_web/live/property_live/show.ex
+++ b/lib/bones73k_web/live/property_live/show.ex
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.PropertyLive.Show do
- use RealEstateWeb, :live_view
+defmodule Bones73kWeb.PropertyLive.Show do
+ use Bones73kWeb, :live_view
- alias RealEstate.Properties
- alias RealEstateWeb.Roles
+ alias Bones73k.Properties
+ alias Bones73kWeb.Roles
@impl true
def mount(_params, session, socket) do
diff --git a/lib/real_estate_web/live/property_live/show.html.leex b/lib/bones73k_web/live/property_live/show.html.leex
similarity index 92%
rename from lib/real_estate_web/live/property_live/show.html.leex
rename to lib/bones73k_web/live/property_live/show.html.leex
index 9da9cf7..cba90a6 100644
--- a/lib/real_estate_web/live/property_live/show.html.leex
+++ b/lib/bones73k_web/live/property_live/show.html.leex
@@ -1,7 +1,7 @@
Show Property
<%= if @live_action in [:edit] do %>
- <%= live_modal @socket, RealEstateWeb.PropertyLive.FormComponent,
+ <%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
id: @property.id,
title: @page_title,
action: @live_action,
diff --git a/lib/real_estate_web/live/user_dashboard_live.ex b/lib/bones73k_web/live/user_dashboard_live.ex
similarity index 78%
rename from lib/real_estate_web/live/user_dashboard_live.ex
rename to lib/bones73k_web/live/user_dashboard_live.ex
index 4a03913..154e419 100644
--- a/lib/real_estate_web/live/user_dashboard_live.ex
+++ b/lib/bones73k_web/live/user_dashboard_live.ex
@@ -1,5 +1,5 @@
-defmodule RealEstateWeb.UserDashboardLive do
- use RealEstateWeb, :live_view
+defmodule Bones73kWeb.UserDashboardLive do
+ use Bones73kWeb, :live_view
@impl true
def mount(_params, session, socket) do
diff --git a/lib/real_estate_web/plugs/ensure_role_plug.ex b/lib/bones73k_web/plugs/ensure_role_plug.ex
similarity index 85%
rename from lib/real_estate_web/plugs/ensure_role_plug.ex
rename to lib/bones73k_web/plugs/ensure_role_plug.ex
index 0543909..8edd2ad 100644
--- a/lib/real_estate_web/plugs/ensure_role_plug.ex
+++ b/lib/bones73k_web/plugs/ensure_role_plug.ex
@@ -1,4 +1,4 @@
-defmodule RealEstateWeb.EnsureRolePlug do
+defmodule Bones73kWeb.EnsureRolePlug do
@moduledoc """
This plug ensures that a user has a particular role before accessing a given route.
@@ -6,15 +6,15 @@ defmodule RealEstateWeb.EnsureRolePlug do
Let's suppose we have three roles: :admin, :manager and :user.
If you want a user to have at least manager role, so admins and managers are authorised to access a given route
- plug RealEstateWeb.EnsureRolePlug, [:admin, :manager]
+ plug Bones73kWeb.EnsureRolePlug, [:admin, :manager]
If you want to give access only to an admin:
- plug RealEstateWeb.EnsureRolePlug, :admin
+ plug Bones73kWeb.EnsureRolePlug, :admin
"""
import Plug.Conn
- alias RealEstate.Accounts
- alias RealEstate.Accounts.User
+ alias Bones73k.Accounts
+ alias Bones73k.Accounts.User
alias Phoenix.Controller
alias Plug.Conn
diff --git a/lib/real_estate_web/roles.ex b/lib/bones73k_web/roles.ex
similarity index 85%
rename from lib/real_estate_web/roles.ex
rename to lib/bones73k_web/roles.ex
index e1b7e2c..6484c32 100644
--- a/lib/real_estate_web/roles.ex
+++ b/lib/bones73k_web/roles.ex
@@ -1,10 +1,10 @@
-defmodule RealEstateWeb.Roles do
+defmodule Bones73kWeb.Roles do
@moduledoc """
Defines roles related functions.
"""
- alias RealEstate.Accounts.User
- alias RealEstate.Properties.Property
+ alias Bones73k.Accounts.User
+ alias Bones73k.Properties.Property
@type entity :: struct()
@type action :: :new | :index | :edit | :show | :delete
diff --git a/lib/bones73k_web/router.ex b/lib/bones73k_web/router.ex
new file mode 100644
index 0000000..43b05b0
--- /dev/null
+++ b/lib/bones73k_web/router.ex
@@ -0,0 +1,103 @@
+defmodule Bones73kWeb.Router do
+ use Bones73kWeb, :router
+ import Bones73kWeb.UserAuth
+ alias Bones73kWeb.EnsureRolePlug
+
+ pipeline :browser do
+ plug(:accepts, ["html"])
+ plug(:fetch_session)
+ plug(:fetch_live_flash)
+ plug(:put_root_layout, {Bones73kWeb.LayoutView, :root})
+ plug(:protect_from_forgery)
+ plug(:put_secure_browser_headers)
+ plug(:fetch_current_user)
+ end
+
+ pipeline :api do
+ plug(:accepts, ["json"])
+ end
+
+ pipeline :user do
+ plug(EnsureRolePlug, [:admin, :user])
+ end
+
+ pipeline :admin do
+ plug(EnsureRolePlug, :admin)
+ end
+
+ # Other scopes may use custom stacks.
+ # scope "/api", Bones73kWeb do
+ # pipe_through :api
+ # end
+
+ # Enables LiveDashboard only for development
+ #
+ # 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,
+ # you can use Plug.BasicAuth to set up some basic authentication
+ # as long as you are also using SSL (which you should anyway).
+ if Mix.env() in [:dev, :test] do
+ import Phoenix.LiveDashboard.Router
+
+ scope "/" do
+ pipe_through(:browser)
+ live_dashboard("/dashboard", metrics: Bones73kWeb.Telemetry)
+ end
+ end
+
+ ## Authentication routes
+
+ scope "/", Bones73kWeb do
+ pipe_through([:browser, :redirect_if_user_is_authenticated])
+
+ get("/users/register", UserRegistrationController, :new)
+ post("/users/register", UserRegistrationController, :create)
+ get("/users/log_in", UserSessionController, :new)
+ post("/users/log_in", UserSessionController, :create)
+ get("/users/reset_password", UserResetPasswordController, :new)
+ post("/users/reset_password", UserResetPasswordController, :create)
+ get("/users/reset_password/:token", UserResetPasswordController, :edit)
+ put("/users/reset_password/:token", UserResetPasswordController, :update)
+ end
+
+ scope "/", Bones73kWeb do
+ pipe_through([:browser, :require_authenticated_user])
+
+ get("/users/settings", UserSettingsController, :edit)
+ put("/users/settings/update_password", UserSettingsController, :update_password)
+ put("/users/settings/update_email", UserSettingsController, :update_email)
+ get("/users/settings/confirm_email/:token", UserSettingsController, :confirm_email)
+
+ # This line was moved
+ live("/", PageLive, :index)
+ end
+
+ scope "/", Bones73kWeb do
+ pipe_through([:browser])
+
+ get("/users/force_logout", UserSessionController, :force_logout)
+ delete("/users/log_out", UserSessionController, :delete)
+ get("/users/confirm", UserConfirmationController, :new)
+ post("/users/confirm", UserConfirmationController, :create)
+ get("/users/confirm/:token", UserConfirmationController, :confirm)
+ end
+
+ scope "/", Bones73kWeb do
+ pipe_through([:browser, :require_authenticated_user, :user])
+
+ live("/user_dashboard", UserDashboardLive, :index)
+
+ live("/properties", PropertyLive.Index, :index)
+ live("/properties/new", PropertyLive.Index, :new)
+ live("/properties/:id/edit", PropertyLive.Index, :edit)
+ live("/properties/:id", PropertyLive.Show, :show)
+ live("/properties/:id/show/edit", PropertyLive.Show, :edit)
+ end
+
+ scope "/", Bones73kWeb do
+ pipe_through([:browser, :require_authenticated_user, :admin])
+
+ live("/admin_dashboard", AdminDashboardLive, :index)
+ end
+end
diff --git a/lib/real_estate_web/telemetry.ex b/lib/bones73k_web/telemetry.ex
similarity index 73%
rename from lib/real_estate_web/telemetry.ex
rename to lib/bones73k_web/telemetry.ex
index 45f651d..6a6c17b 100644
--- a/lib/real_estate_web/telemetry.ex
+++ b/lib/bones73k_web/telemetry.ex
@@ -1,4 +1,4 @@
-defmodule RealEstateWeb.Telemetry do
+defmodule Bones73kWeb.Telemetry do
use Supervisor
import Telemetry.Metrics
@@ -31,11 +31,11 @@ defmodule RealEstateWeb.Telemetry do
),
# Database Metrics
- summary("real_estate.repo.query.total_time", unit: {:native, :millisecond}),
- summary("real_estate.repo.query.decode_time", unit: {:native, :millisecond}),
- summary("real_estate.repo.query.query_time", unit: {:native, :millisecond}),
- summary("real_estate.repo.query.queue_time", unit: {:native, :millisecond}),
- summary("real_estate.repo.query.idle_time", unit: {:native, :millisecond}),
+ summary("bones73k.repo.query.total_time", unit: {:native, :millisecond}),
+ summary("bones73k.repo.query.decode_time", unit: {:native, :millisecond}),
+ summary("bones73k.repo.query.query_time", unit: {:native, :millisecond}),
+ summary("bones73k.repo.query.queue_time", unit: {:native, :millisecond}),
+ summary("bones73k.repo.query.idle_time", unit: {:native, :millisecond}),
# VM Metrics
summary("vm.memory.total", unit: {:byte, :kilobyte}),
@@ -49,7 +49,7 @@ defmodule RealEstateWeb.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.
- # {RealEstateWeb, :count_users, []}
+ # {Bones73kWeb, :count_users, []}
]
end
end
diff --git a/lib/real_estate_web/templates/layout/_user_menu.html.eex b/lib/bones73k_web/templates/layout/_user_menu.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/layout/_user_menu.html.eex
rename to lib/bones73k_web/templates/layout/_user_menu.html.eex
diff --git a/lib/real_estate_web/templates/layout/app.html.eex b/lib/bones73k_web/templates/layout/app.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/layout/app.html.eex
rename to lib/bones73k_web/templates/layout/app.html.eex
diff --git a/lib/real_estate_web/templates/layout/live.html.leex b/lib/bones73k_web/templates/layout/live.html.leex
similarity index 100%
rename from lib/real_estate_web/templates/layout/live.html.leex
rename to lib/bones73k_web/templates/layout/live.html.leex
diff --git a/lib/real_estate_web/templates/layout/root.html.leex b/lib/bones73k_web/templates/layout/root.html.leex
similarity index 92%
rename from lib/real_estate_web/templates/layout/root.html.leex
rename to lib/bones73k_web/templates/layout/root.html.leex
index 95a8726..9952190 100644
--- a/lib/real_estate_web/templates/layout/root.html.leex
+++ b/lib/bones73k_web/templates/layout/root.html.leex
@@ -5,7 +5,7 @@
<%= csrf_meta_tag() %>
- <%= live_title_tag assigns[:page_title] || "RealEstate", suffix: " · Phoenix Framework" %>
+ <%= live_title_tag assigns[:page_title] || "Bones73k", suffix: " · Phoenix Framework" %>
"/>
diff --git a/lib/real_estate_web/templates/user_confirmation/new.html.eex b/lib/bones73k_web/templates/user_confirmation/new.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/user_confirmation/new.html.eex
rename to lib/bones73k_web/templates/user_confirmation/new.html.eex
diff --git a/lib/real_estate_web/templates/user_registration/new.html.eex b/lib/bones73k_web/templates/user_registration/new.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/user_registration/new.html.eex
rename to lib/bones73k_web/templates/user_registration/new.html.eex
diff --git a/lib/real_estate_web/templates/user_reset_password/edit.html.eex b/lib/bones73k_web/templates/user_reset_password/edit.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/user_reset_password/edit.html.eex
rename to lib/bones73k_web/templates/user_reset_password/edit.html.eex
diff --git a/lib/real_estate_web/templates/user_reset_password/new.html.eex b/lib/bones73k_web/templates/user_reset_password/new.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/user_reset_password/new.html.eex
rename to lib/bones73k_web/templates/user_reset_password/new.html.eex
diff --git a/lib/real_estate_web/templates/user_session/new.html.eex b/lib/bones73k_web/templates/user_session/new.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/user_session/new.html.eex
rename to lib/bones73k_web/templates/user_session/new.html.eex
diff --git a/lib/real_estate_web/templates/user_settings/edit.html.eex b/lib/bones73k_web/templates/user_settings/edit.html.eex
similarity index 100%
rename from lib/real_estate_web/templates/user_settings/edit.html.eex
rename to lib/bones73k_web/templates/user_settings/edit.html.eex
diff --git a/lib/real_estate_web/views/error_helpers.ex b/lib/bones73k_web/views/error_helpers.ex
similarity index 87%
rename from lib/real_estate_web/views/error_helpers.ex
rename to lib/bones73k_web/views/error_helpers.ex
index 62b2180..9296952 100644
--- a/lib/real_estate_web/views/error_helpers.ex
+++ b/lib/bones73k_web/views/error_helpers.ex
@@ -1,4 +1,4 @@
-defmodule RealEstateWeb.ErrorHelpers do
+defmodule Bones73kWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
@@ -39,9 +39,9 @@ defmodule RealEstateWeb.ErrorHelpers do
# should be written to the errors.po file. The :count option is
# set by Ecto and indicates we should also apply plural rules.
if count = opts[:count] do
- Gettext.dngettext(RealEstateWeb.Gettext, "errors", msg, msg, count, opts)
+ Gettext.dngettext(Bones73kWeb.Gettext, "errors", msg, msg, count, opts)
else
- Gettext.dgettext(RealEstateWeb.Gettext, "errors", msg, opts)
+ Gettext.dgettext(Bones73kWeb.Gettext, "errors", msg, opts)
end
end
end
diff --git a/lib/real_estate_web/views/error_view.ex b/lib/bones73k_web/views/error_view.ex
similarity index 87%
rename from lib/real_estate_web/views/error_view.ex
rename to lib/bones73k_web/views/error_view.ex
index b6b2384..67ce167 100644
--- a/lib/real_estate_web/views/error_view.ex
+++ b/lib/bones73k_web/views/error_view.ex
@@ -1,5 +1,5 @@
-defmodule RealEstateWeb.ErrorView do
- use RealEstateWeb, :view
+defmodule Bones73kWeb.ErrorView do
+ use Bones73kWeb, :view
# If you want to customize a particular status code
# for a certain format, you may uncomment below.
diff --git a/lib/bones73k_web/views/layout_view.ex b/lib/bones73k_web/views/layout_view.ex
new file mode 100644
index 0000000..a0e3a46
--- /dev/null
+++ b/lib/bones73k_web/views/layout_view.ex
@@ -0,0 +1,3 @@
+defmodule Bones73kWeb.LayoutView do
+ use Bones73kWeb, :view
+end
diff --git a/lib/bones73k_web/views/user_confirmation_view.ex b/lib/bones73k_web/views/user_confirmation_view.ex
new file mode 100644
index 0000000..7ba1a84
--- /dev/null
+++ b/lib/bones73k_web/views/user_confirmation_view.ex
@@ -0,0 +1,3 @@
+defmodule Bones73kWeb.UserConfirmationView do
+ use Bones73kWeb, :view
+end
diff --git a/lib/bones73k_web/views/user_registration_view.ex b/lib/bones73k_web/views/user_registration_view.ex
new file mode 100644
index 0000000..9024c56
--- /dev/null
+++ b/lib/bones73k_web/views/user_registration_view.ex
@@ -0,0 +1,3 @@
+defmodule Bones73kWeb.UserRegistrationView do
+ use Bones73kWeb, :view
+end
diff --git a/lib/bones73k_web/views/user_reset_password_view.ex b/lib/bones73k_web/views/user_reset_password_view.ex
new file mode 100644
index 0000000..c8a1f90
--- /dev/null
+++ b/lib/bones73k_web/views/user_reset_password_view.ex
@@ -0,0 +1,3 @@
+defmodule Bones73kWeb.UserResetPasswordView do
+ use Bones73kWeb, :view
+end
diff --git a/lib/bones73k_web/views/user_session_view.ex b/lib/bones73k_web/views/user_session_view.ex
new file mode 100644
index 0000000..4f5a1e9
--- /dev/null
+++ b/lib/bones73k_web/views/user_session_view.ex
@@ -0,0 +1,3 @@
+defmodule Bones73kWeb.UserSessionView do
+ use Bones73kWeb, :view
+end
diff --git a/lib/bones73k_web/views/user_settings_view.ex b/lib/bones73k_web/views/user_settings_view.ex
new file mode 100644
index 0000000..27735e8
--- /dev/null
+++ b/lib/bones73k_web/views/user_settings_view.ex
@@ -0,0 +1,3 @@
+defmodule Bones73kWeb.UserSettingsView do
+ use Bones73kWeb, :view
+end
diff --git a/lib/real_estate_web/router.ex b/lib/real_estate_web/router.ex
deleted file mode 100644
index 13ffed8..0000000
--- a/lib/real_estate_web/router.ex
+++ /dev/null
@@ -1,103 +0,0 @@
-defmodule RealEstateWeb.Router do
- use RealEstateWeb, :router
- import RealEstateWeb.UserAuth
- alias RealEstateWeb.EnsureRolePlug
-
- pipeline :browser do
- plug :accepts, ["html"]
- plug :fetch_session
- plug :fetch_live_flash
- plug :put_root_layout, {RealEstateWeb.LayoutView, :root}
- plug :protect_from_forgery
- plug :put_secure_browser_headers
- plug :fetch_current_user
- end
-
- pipeline :api do
- plug :accepts, ["json"]
- end
-
- pipeline :user do
- plug EnsureRolePlug, [:admin, :user]
- end
-
- pipeline :admin do
- plug EnsureRolePlug, :admin
- end
-
- # Other scopes may use custom stacks.
- # scope "/api", RealEstateWeb do
- # pipe_through :api
- # end
-
- # Enables LiveDashboard only for development
- #
- # 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,
- # you can use Plug.BasicAuth to set up some basic authentication
- # as long as you are also using SSL (which you should anyway).
- if Mix.env() in [:dev, :test] do
- import Phoenix.LiveDashboard.Router
-
- scope "/" do
- pipe_through :browser
- live_dashboard "/dashboard", metrics: RealEstateWeb.Telemetry
- end
- end
-
- ## Authentication routes
-
- scope "/", RealEstateWeb do
- pipe_through [:browser, :redirect_if_user_is_authenticated]
-
- get "/users/register", UserRegistrationController, :new
- post "/users/register", UserRegistrationController, :create
- get "/users/log_in", UserSessionController, :new
- post "/users/log_in", UserSessionController, :create
- get "/users/reset_password", UserResetPasswordController, :new
- post "/users/reset_password", UserResetPasswordController, :create
- get "/users/reset_password/:token", UserResetPasswordController, :edit
- put "/users/reset_password/:token", UserResetPasswordController, :update
- end
-
- scope "/", RealEstateWeb do
- pipe_through [:browser, :require_authenticated_user]
-
- get "/users/settings", UserSettingsController, :edit
- put "/users/settings/update_password", UserSettingsController, :update_password
- put "/users/settings/update_email", UserSettingsController, :update_email
- get "/users/settings/confirm_email/:token", UserSettingsController, :confirm_email
-
- # This line was moved
- live "/", PageLive, :index
- end
-
- scope "/", RealEstateWeb do
- pipe_through [:browser]
-
- get "/users/force_logout", UserSessionController, :force_logout
- delete "/users/log_out", UserSessionController, :delete
- get "/users/confirm", UserConfirmationController, :new
- post "/users/confirm", UserConfirmationController, :create
- get "/users/confirm/:token", UserConfirmationController, :confirm
- end
-
- scope "/", RealEstateWeb do
- pipe_through [:browser, :require_authenticated_user, :user]
-
- live "/user_dashboard", UserDashboardLive, :index
-
- live "/properties", PropertyLive.Index, :index
- live "/properties/new", PropertyLive.Index, :new
- live "/properties/:id/edit", PropertyLive.Index, :edit
- live "/properties/:id", PropertyLive.Show, :show
- live "/properties/:id/show/edit", PropertyLive.Show, :edit
- end
-
- scope "/", RealEstateWeb do
- pipe_through [:browser, :require_authenticated_user, :admin]
-
- live "/admin_dashboard", AdminDashboardLive, :index
- end
-end
diff --git a/lib/real_estate_web/views/layout_view.ex b/lib/real_estate_web/views/layout_view.ex
deleted file mode 100644
index 36f6542..0000000
--- a/lib/real_estate_web/views/layout_view.ex
+++ /dev/null
@@ -1,3 +0,0 @@
-defmodule RealEstateWeb.LayoutView do
- use RealEstateWeb, :view
-end
diff --git a/lib/real_estate_web/views/user_confirmation_view.ex b/lib/real_estate_web/views/user_confirmation_view.ex
deleted file mode 100644
index 959b5c1..0000000
--- a/lib/real_estate_web/views/user_confirmation_view.ex
+++ /dev/null
@@ -1,3 +0,0 @@
-defmodule RealEstateWeb.UserConfirmationView do
- use RealEstateWeb, :view
-end
diff --git a/lib/real_estate_web/views/user_registration_view.ex b/lib/real_estate_web/views/user_registration_view.ex
deleted file mode 100644
index efa6357..0000000
--- a/lib/real_estate_web/views/user_registration_view.ex
+++ /dev/null
@@ -1,3 +0,0 @@
-defmodule RealEstateWeb.UserRegistrationView do
- use RealEstateWeb, :view
-end
diff --git a/lib/real_estate_web/views/user_reset_password_view.ex b/lib/real_estate_web/views/user_reset_password_view.ex
deleted file mode 100644
index 6f95fd2..0000000
--- a/lib/real_estate_web/views/user_reset_password_view.ex
+++ /dev/null
@@ -1,3 +0,0 @@
-defmodule RealEstateWeb.UserResetPasswordView do
- use RealEstateWeb, :view
-end
diff --git a/lib/real_estate_web/views/user_session_view.ex b/lib/real_estate_web/views/user_session_view.ex
deleted file mode 100644
index e352f3c..0000000
--- a/lib/real_estate_web/views/user_session_view.ex
+++ /dev/null
@@ -1,3 +0,0 @@
-defmodule RealEstateWeb.UserSessionView do
- use RealEstateWeb, :view
-end
diff --git a/lib/real_estate_web/views/user_settings_view.ex b/lib/real_estate_web/views/user_settings_view.ex
deleted file mode 100644
index 591c1ff..0000000
--- a/lib/real_estate_web/views/user_settings_view.ex
+++ /dev/null
@@ -1,3 +0,0 @@
-defmodule RealEstateWeb.UserSettingsView do
- use RealEstateWeb, :view
-end
diff --git a/mix.exs b/mix.exs
index 77a7702..619f81d 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,9 +1,9 @@
-defmodule RealEstate.MixProject do
+defmodule Bones73k.MixProject do
use Mix.Project
def project do
[
- app: :real_estate,
+ app: :bones73k,
version: "0.1.0",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
@@ -19,7 +19,7 @@ defmodule RealEstate.MixProject do
# Type `mix help compile.app` for more information.
def application do
[
- mod: {RealEstate.Application, []},
+ mod: {Bones73k.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
diff --git a/priv/repo/migrations/20200913000515_create_users_auth_tables.exs b/priv/repo/migrations/20200913000515_create_users_auth_tables.exs
index 9bb24ab..bdcc744 100644
--- a/priv/repo/migrations/20200913000515_create_users_auth_tables.exs
+++ b/priv/repo/migrations/20200913000515_create_users_auth_tables.exs
@@ -1,27 +1,27 @@
-defmodule RealEstate.Repo.Migrations.CreateUsersAuthTables do
+defmodule Bones73k.Repo.Migrations.CreateUsersAuthTables do
use Ecto.Migration
def change do
- execute "CREATE EXTENSION IF NOT EXISTS citext", ""
+ execute("CREATE EXTENSION IF NOT EXISTS citext", "")
create table(:users) do
- add :email, :citext, null: false
- add :hashed_password, :string, null: false
- add :confirmed_at, :naive_datetime
+ add(:email, :citext, null: false)
+ add(:hashed_password, :string, null: false)
+ add(:confirmed_at, :naive_datetime)
timestamps()
end
- create unique_index(:users, [:email])
+ create(unique_index(:users, [:email]))
create table(:users_tokens) do
- add :user_id, references(:users, on_delete: :delete_all), null: false
- add :token, :binary, null: false
- add :context, :string, null: false
- add :sent_to, :string
+ add(:user_id, references(:users, on_delete: :delete_all), null: false)
+ add(:token, :binary, null: false)
+ add(:context, :string, null: false)
+ add(:sent_to, :string)
timestamps(updated_at: false)
end
- create index(:users_tokens, [:user_id])
- create unique_index(:users_tokens, [:context, :token])
+ create(index(:users_tokens, [:user_id]))
+ create(unique_index(:users_tokens, [:context, :token]))
end
end
diff --git a/priv/repo/migrations/20200913000905_add_role_to_users.exs b/priv/repo/migrations/20200913000905_add_role_to_users.exs
index c400c65..68b32a6 100644
--- a/priv/repo/migrations/20200913000905_add_role_to_users.exs
+++ b/priv/repo/migrations/20200913000905_add_role_to_users.exs
@@ -1,19 +1,19 @@
-defmodule RealEstate.Repo.Migrations.AddRoleToUsers do
+defmodule Bones73k.Repo.Migrations.AddRoleToUsers do
use Ecto.Migration
- alias RealEstate.Accounts.User.RolesEnum
+ alias Bones73k.Accounts.User.RolesEnum
def up do
RolesEnum.create_type()
alter table(:users) do
- add :role, RolesEnum.type(), null: false
+ add(:role, RolesEnum.type(), null: false)
end
end
def down do
alter table(:users) do
- remove :role
+ remove(:role)
end
RolesEnum.drop_type()
diff --git a/priv/repo/migrations/20200914162043_create_properties.exs b/priv/repo/migrations/20200914162043_create_properties.exs
index 15b61da..97f3ec0 100644
--- a/priv/repo/migrations/20200914162043_create_properties.exs
+++ b/priv/repo/migrations/20200914162043_create_properties.exs
@@ -1,16 +1,16 @@
-defmodule RealEstate.Repo.Migrations.CreateProperties do
+defmodule Bones73k.Repo.Migrations.CreateProperties do
use Ecto.Migration
def change do
create table(:properties) do
- add :name, :string
- add :price, :decimal
- add :description, :text
- add :user_id, references(:users, on_delete: :nothing)
+ add(:name, :string)
+ add(:price, :decimal)
+ add(:description, :text)
+ add(:user_id, references(:users, on_delete: :nothing))
timestamps()
end
- create index(:properties, [:user_id])
+ create(index(:properties, [:user_id]))
end
end
diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs
index 9a9f5c2..5da03cd 100644
--- a/priv/repo/seeds.exs
+++ b/priv/repo/seeds.exs
@@ -5,27 +5,27 @@
# Inside the script, you can read and write to any of your
# repositories directly:
#
-# RealEstate.Repo.insert!(%RealEstate.SomeSchema{})
+# Bones73k.Repo.insert!(%Bones73k.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
{:ok, admin} =
- RealEstate.Accounts.register_admin(%{
+ Bones73k.Accounts.register_admin(%{
email: "admin@company.com",
password: "123456789abc",
password_confirmation: "123456789abc"
})
{:ok, user_1} =
- RealEstate.Accounts.register_user(%{
+ Bones73k.Accounts.register_user(%{
email: "user1@company.com",
password: "123456789abc",
password_confirmation: "123456789abc"
})
{:ok, user_2} =
- RealEstate.Accounts.register_user(%{
+ Bones73k.Accounts.register_user(%{
email: "user2@company.com",
password: "123456789abc",
password_confirmation: "123456789abc"
@@ -38,7 +38,7 @@ Enum.each(1..10, fn i ->
description: "Property that belongs to user 1",
user_id: user_1.id
}
- |> RealEstate.Properties.create_property()
+ |> Bones73k.Properties.create_property()
%{
name: "Property #{i} - User 2",
@@ -46,7 +46,7 @@ Enum.each(1..10, fn i ->
description: "Property that belongs to user 2",
user_id: user_2.id
}
- |> RealEstate.Properties.create_property()
+ |> Bones73k.Properties.create_property()
%{
name: "Property #{i} - Admin",
@@ -54,5 +54,5 @@ Enum.each(1..10, fn i ->
description: "Property that belongs to admin",
user_id: admin.id
}
- |> RealEstate.Properties.create_property()
+ |> Bones73k.Properties.create_property()
end)
diff --git a/test/real_estate/accounts_test.exs b/test/bones73k/accounts_test.exs
similarity index 98%
rename from test/real_estate/accounts_test.exs
rename to test/bones73k/accounts_test.exs
index 3c37fbc..f12d70f 100644
--- a/test/real_estate/accounts_test.exs
+++ b/test/bones73k/accounts_test.exs
@@ -1,9 +1,9 @@
-defmodule RealEstate.AccountsTest do
- use RealEstate.DataCase
+defmodule Bones73k.AccountsTest do
+ use Bones73k.DataCase
- alias RealEstate.Accounts
- import RealEstate.AccountsFixtures
- alias RealEstate.Accounts.{User, UserToken}
+ alias Bones73k.Accounts
+ import Bones73k.AccountsFixtures
+ alias Bones73k.Accounts.{User, UserToken}
describe "get_user_by_email/1" do
test "does not return the user if the email does not exist" do
diff --git a/test/real_estate/properties_test.exs b/test/bones73k/properties_test.exs
similarity index 94%
rename from test/real_estate/properties_test.exs
rename to test/bones73k/properties_test.exs
index faa853d..f930a79 100644
--- a/test/real_estate/properties_test.exs
+++ b/test/bones73k/properties_test.exs
@@ -1,11 +1,11 @@
-defmodule RealEstate.PropertiesTest do
- use RealEstate.DataCase
+defmodule Bones73k.PropertiesTest do
+ use Bones73k.DataCase
- alias RealEstate.Properties
- import RealEstate.AccountsFixtures
+ alias Bones73k.Properties
+ import Bones73k.AccountsFixtures
describe "properties" do
- alias RealEstate.Properties.Property
+ alias Bones73k.Properties.Property
@valid_attrs %{description: "some description", name: "some name", price: "120.5"}
@update_attrs %{
diff --git a/test/real_estate_web/controllers/user_auth_test.exs b/test/bones73k_web/controllers/user_auth_test.exs
similarity index 94%
rename from test/real_estate_web/controllers/user_auth_test.exs
rename to test/bones73k_web/controllers/user_auth_test.exs
index d2e49a9..30e0d9f 100644
--- a/test/real_estate_web/controllers/user_auth_test.exs
+++ b/test/bones73k_web/controllers/user_auth_test.exs
@@ -1,14 +1,14 @@
-defmodule RealEstateWeb.UserAuthTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.UserAuthTest do
+ use Bones73kWeb.ConnCase, async: true
- alias RealEstate.Accounts
- alias RealEstateWeb.UserAuth
- import RealEstate.AccountsFixtures
+ alias Bones73k.Accounts
+ alias Bones73kWeb.UserAuth
+ import Bones73k.AccountsFixtures
setup %{conn: conn} do
conn =
conn
- |> Map.replace!(:secret_key_base, RealEstateWeb.Endpoint.config(:secret_key_base))
+ |> Map.replace!(:secret_key_base, Bones73kWeb.Endpoint.config(:secret_key_base))
|> init_test_session(%{})
%{user: user_fixture(), conn: conn}
@@ -63,7 +63,7 @@ defmodule RealEstateWeb.UserAuthTest do
test "broadcasts to the given live_socket_id", %{conn: conn} do
live_socket_id = "users_sessions:abcdef-token"
- RealEstateWeb.Endpoint.subscribe(live_socket_id)
+ Bones73kWeb.Endpoint.subscribe(live_socket_id)
conn
|> put_session(:live_socket_id, live_socket_id)
diff --git a/test/real_estate_web/controllers/user_confirmation_controller_test.exs b/test/bones73k_web/controllers/user_confirmation_controller_test.exs
similarity index 93%
rename from test/real_estate_web/controllers/user_confirmation_controller_test.exs
rename to test/bones73k_web/controllers/user_confirmation_controller_test.exs
index 9d52dab..bc0ea4f 100644
--- a/test/real_estate_web/controllers/user_confirmation_controller_test.exs
+++ b/test/bones73k_web/controllers/user_confirmation_controller_test.exs
@@ -1,9 +1,9 @@
-defmodule RealEstateWeb.UserConfirmationControllerTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.UserConfirmationControllerTest do
+ use Bones73kWeb.ConnCase, async: true
- alias RealEstate.Accounts
- alias RealEstate.Repo
- import RealEstate.AccountsFixtures
+ alias Bones73k.Accounts
+ alias Bones73k.Repo
+ import Bones73k.AccountsFixtures
setup do
%{user: user_fixture()}
diff --git a/test/real_estate_web/controllers/user_registration_controller_test.exs b/test/bones73k_web/controllers/user_registration_controller_test.exs
similarity index 92%
rename from test/real_estate_web/controllers/user_registration_controller_test.exs
rename to test/bones73k_web/controllers/user_registration_controller_test.exs
index 29ee59b..ad8d4c3 100644
--- a/test/real_estate_web/controllers/user_registration_controller_test.exs
+++ b/test/bones73k_web/controllers/user_registration_controller_test.exs
@@ -1,7 +1,7 @@
-defmodule RealEstateWeb.UserRegistrationControllerTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.UserRegistrationControllerTest do
+ use Bones73kWeb.ConnCase, async: true
- import RealEstate.AccountsFixtures
+ import Bones73k.AccountsFixtures
describe "GET /users/register" do
test "renders registration page", %{conn: conn} do
diff --git a/test/real_estate_web/controllers/user_reset_password_controller_test.exs b/test/bones73k_web/controllers/user_reset_password_controller_test.exs
similarity index 95%
rename from test/real_estate_web/controllers/user_reset_password_controller_test.exs
rename to test/bones73k_web/controllers/user_reset_password_controller_test.exs
index a35e1fe..1b429b8 100644
--- a/test/real_estate_web/controllers/user_reset_password_controller_test.exs
+++ b/test/bones73k_web/controllers/user_reset_password_controller_test.exs
@@ -1,9 +1,9 @@
-defmodule RealEstateWeb.UserResetPasswordControllerTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.UserResetPasswordControllerTest do
+ use Bones73kWeb.ConnCase, async: true
- alias RealEstate.Accounts
- alias RealEstate.Repo
- import RealEstate.AccountsFixtures
+ alias Bones73k.Accounts
+ alias Bones73k.Repo
+ import Bones73k.AccountsFixtures
setup do
%{user: user_fixture()}
diff --git a/test/real_estate_web/controllers/user_session_controller_test.exs b/test/bones73k_web/controllers/user_session_controller_test.exs
similarity index 95%
rename from test/real_estate_web/controllers/user_session_controller_test.exs
rename to test/bones73k_web/controllers/user_session_controller_test.exs
index 724737a..dc1f2cf 100644
--- a/test/real_estate_web/controllers/user_session_controller_test.exs
+++ b/test/bones73k_web/controllers/user_session_controller_test.exs
@@ -1,7 +1,7 @@
-defmodule RealEstateWeb.UserSessionControllerTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.UserSessionControllerTest do
+ use Bones73kWeb.ConnCase, async: true
- import RealEstate.AccountsFixtures
+ import Bones73k.AccountsFixtures
setup do
%{user: user_fixture()}
diff --git a/test/real_estate_web/controllers/user_settings_controller_test.exs b/test/bones73k_web/controllers/user_settings_controller_test.exs
similarity index 96%
rename from test/real_estate_web/controllers/user_settings_controller_test.exs
rename to test/bones73k_web/controllers/user_settings_controller_test.exs
index 263b822..94dc734 100644
--- a/test/real_estate_web/controllers/user_settings_controller_test.exs
+++ b/test/bones73k_web/controllers/user_settings_controller_test.exs
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.UserSettingsControllerTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.UserSettingsControllerTest do
+ use Bones73kWeb.ConnCase, async: true
- alias RealEstate.Accounts
- import RealEstate.AccountsFixtures
+ alias Bones73k.Accounts
+ import Bones73k.AccountsFixtures
setup :register_and_log_in_user
diff --git a/test/real_estate_web/live/admin_dashboard_live_test.exs b/test/bones73k_web/live/admin_dashboard_live_test.exs
similarity index 93%
rename from test/real_estate_web/live/admin_dashboard_live_test.exs
rename to test/bones73k_web/live/admin_dashboard_live_test.exs
index 47973d9..356529d 100644
--- a/test/real_estate_web/live/admin_dashboard_live_test.exs
+++ b/test/bones73k_web/live/admin_dashboard_live_test.exs
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.AdminDashboardLiveTest do
- use RealEstateWeb.ConnCase
+defmodule Bones73kWeb.AdminDashboardLiveTest do
+ use Bones73kWeb.ConnCase
import Phoenix.LiveViewTest
- import RealEstate.AccountsFixtures
+ import Bones73k.AccountsFixtures
test "disconnected and connected render without authentication should redirect to login page",
%{conn: conn} do
@@ -38,7 +38,7 @@ defmodule RealEstateWeb.AdminDashboardLiveTest do
assert disconnected_html =~ "Welcome to the admin dashboard!"
assert render(admin_dashboard) =~ "Welcome to the admin dashboard!"
- RealEstate.Accounts.logout_user(admin)
+ Bones73k.Accounts.logout_user(admin)
# Assert our liveview process is down
ref = Process.monitor(admin_dashboard.pid)
@@ -70,7 +70,7 @@ defmodule RealEstateWeb.AdminDashboardLiveTest do
assert disconnected_html =~ "Welcome to the admin dashboard!"
assert render(admin_dashboard) =~ "Welcome to the admin dashboard!"
- RealEstate.Accounts.logout_user(admin2)
+ Bones73k.Accounts.logout_user(admin2)
# Assert our liveview is alive
ref = Process.monitor(admin_dashboard.pid)
diff --git a/test/real_estate_web/live/page_live_test.exs b/test/bones73k_web/live/page_live_test.exs
similarity index 92%
rename from test/real_estate_web/live/page_live_test.exs
rename to test/bones73k_web/live/page_live_test.exs
index 9052f4c..b8719e7 100644
--- a/test/real_estate_web/live/page_live_test.exs
+++ b/test/bones73k_web/live/page_live_test.exs
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.PageLiveTest do
- use RealEstateWeb.ConnCase
+defmodule Bones73kWeb.PageLiveTest do
+ use Bones73kWeb.ConnCase
import Phoenix.LiveViewTest
- import RealEstate.AccountsFixtures
+ import Bones73k.AccountsFixtures
test "disconnected and connected render without authentication should redirect to login page",
%{conn: conn} do
@@ -30,7 +30,7 @@ defmodule RealEstateWeb.PageLiveTest do
assert disconnected_html =~ "Welcome to Phoenix!"
assert render(page_live) =~ "Welcome to Phoenix!"
- RealEstate.Accounts.logout_user(user)
+ Bones73k.Accounts.logout_user(user)
# Assert our liveview process is down
ref = Process.monitor(page_live.pid)
@@ -62,7 +62,7 @@ defmodule RealEstateWeb.PageLiveTest do
assert disconnected_html =~ "Welcome to Phoenix!"
assert render(page_live) =~ "Welcome to Phoenix!"
- RealEstate.Accounts.logout_user(user1)
+ Bones73k.Accounts.logout_user(user1)
# Assert our liveview is alive
ref = Process.monitor(page_live.pid)
diff --git a/test/real_estate_web/live/property_live_test.exs b/test/bones73k_web/live/property_live_test.exs
similarity index 97%
rename from test/real_estate_web/live/property_live_test.exs
rename to test/bones73k_web/live/property_live_test.exs
index 63972e8..522cf25 100644
--- a/test/real_estate_web/live/property_live_test.exs
+++ b/test/bones73k_web/live/property_live_test.exs
@@ -1,10 +1,10 @@
-defmodule RealEstateWeb.PropertyLiveTest do
- use RealEstateWeb.ConnCase
+defmodule Bones73kWeb.PropertyLiveTest do
+ use Bones73kWeb.ConnCase
import Phoenix.LiveViewTest
- import RealEstate.AccountsFixtures
+ import Bones73k.AccountsFixtures
- alias RealEstate.Properties
+ alias Bones73k.Properties
@create_attrs %{description: "some description", name: "some name", price: "120.5"}
@update_attrs %{
@@ -181,7 +181,7 @@ defmodule RealEstateWeb.PropertyLiveTest do
assert html =~ "Listing Properties"
assert render(index_live) =~ "Listing Properties"
- RealEstate.Accounts.logout_user(user)
+ Bones73k.Accounts.logout_user(user)
# Assert our liveview process is down
ref = Process.monitor(index_live.pid)
@@ -214,7 +214,7 @@ defmodule RealEstateWeb.PropertyLiveTest do
assert html =~ "Listing Properties"
assert render(index_live) =~ "Listing Properties"
- RealEstate.Accounts.logout_user(user1)
+ Bones73k.Accounts.logout_user(user1)
# Assert our liveview is alive
ref = Process.monitor(index_live.pid)
@@ -324,7 +324,7 @@ defmodule RealEstateWeb.PropertyLiveTest do
assert html =~ property.description
assert render(show_live) =~ property.description
- RealEstate.Accounts.logout_user(user)
+ Bones73k.Accounts.logout_user(user)
# Assert our liveview process is down
ref = Process.monitor(show_live.pid)
@@ -356,7 +356,7 @@ defmodule RealEstateWeb.PropertyLiveTest do
assert html =~ property.description
assert render(show_live) =~ property.description
- RealEstate.Accounts.logout_user(user1)
+ Bones73k.Accounts.logout_user(user1)
# Assert our liveview is alive
ref = Process.monitor(show_live.pid)
diff --git a/test/real_estate_web/live/user_dashboard_live_test.exs b/test/bones73k_web/live/user_dashboard_live_test.exs
similarity index 93%
rename from test/real_estate_web/live/user_dashboard_live_test.exs
rename to test/bones73k_web/live/user_dashboard_live_test.exs
index 350062d..a0f4e8b 100644
--- a/test/real_estate_web/live/user_dashboard_live_test.exs
+++ b/test/bones73k_web/live/user_dashboard_live_test.exs
@@ -1,8 +1,8 @@
-defmodule RealEstateWeb.UserDashboardLiveTest do
- use RealEstateWeb.ConnCase
+defmodule Bones73kWeb.UserDashboardLiveTest do
+ use Bones73kWeb.ConnCase
import Phoenix.LiveViewTest
- import RealEstate.AccountsFixtures
+ import Bones73k.AccountsFixtures
test "disconnected and connected render without authentication should redirect to login page",
%{conn: conn} do
@@ -40,7 +40,7 @@ defmodule RealEstateWeb.UserDashboardLiveTest do
assert disconnected_html =~ "Welcome to the user dashboard!"
assert render(user_dashboard) =~ "Welcome to the user dashboard!"
- RealEstate.Accounts.logout_user(user)
+ Bones73k.Accounts.logout_user(user)
# Assert our liveview process is down
ref = Process.monitor(user_dashboard.pid)
@@ -72,7 +72,7 @@ defmodule RealEstateWeb.UserDashboardLiveTest do
assert disconnected_html =~ "Welcome to the user dashboard!"
assert render(user_dashboard) =~ "Welcome to the user dashboard!"
- RealEstate.Accounts.logout_user(user2)
+ Bones73k.Accounts.logout_user(user2)
# Assert our liveview is alive
ref = Process.monitor(user_dashboard.pid)
diff --git a/test/bones73k_web/views/error_view_test.exs b/test/bones73k_web/views/error_view_test.exs
new file mode 100644
index 0000000..2959ea2
--- /dev/null
+++ b/test/bones73k_web/views/error_view_test.exs
@@ -0,0 +1,14 @@
+defmodule Bones73kWeb.ErrorViewTest do
+ use Bones73kWeb.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"
+ end
+
+ test "renders 500.html" do
+ assert render_to_string(Bones73kWeb.ErrorView, "500.html", []) == "Internal Server Error"
+ end
+end
diff --git a/test/real_estate_web/views/layout_view_test.exs b/test/bones73k_web/views/layout_view_test.exs
similarity index 69%
rename from test/real_estate_web/views/layout_view_test.exs
rename to test/bones73k_web/views/layout_view_test.exs
index fa12fd3..ce5c67e 100644
--- a/test/real_estate_web/views/layout_view_test.exs
+++ b/test/bones73k_web/views/layout_view_test.exs
@@ -1,5 +1,5 @@
-defmodule RealEstateWeb.LayoutViewTest do
- use RealEstateWeb.ConnCase, async: true
+defmodule Bones73kWeb.LayoutViewTest do
+ use Bones73kWeb.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
diff --git a/test/real_estate_web/views/error_view_test.exs b/test/real_estate_web/views/error_view_test.exs
deleted file mode 100644
index 7470cc7..0000000
--- a/test/real_estate_web/views/error_view_test.exs
+++ /dev/null
@@ -1,14 +0,0 @@
-defmodule RealEstateWeb.ErrorViewTest do
- use RealEstateWeb.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(RealEstateWeb.ErrorView, "404.html", []) == "Not Found"
- end
-
- test "renders 500.html" do
- assert render_to_string(RealEstateWeb.ErrorView, "500.html", []) == "Internal Server Error"
- end
-end
diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex
index 47034df..c3a7bdb 100644
--- a/test/support/channel_case.ex
+++ b/test/support/channel_case.ex
@@ -1,4 +1,4 @@
-defmodule RealEstateWeb.ChannelCase do
+defmodule Bones73kWeb.ChannelCase do
@moduledoc """
This module defines the test case to be used by
channel tests.
@@ -11,7 +11,7 @@ defmodule RealEstateWeb.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 RealEstateWeb.ChannelCase, async: true`, although
+ by setting `use Bones73kWeb.ChannelCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -21,18 +21,18 @@ defmodule RealEstateWeb.ChannelCase do
quote do
# Import conveniences for testing with channels
import Phoenix.ChannelTest
- import RealEstateWeb.ChannelCase
+ import Bones73kWeb.ChannelCase
# The default endpoint for testing
- @endpoint RealEstateWeb.Endpoint
+ @endpoint Bones73kWeb.Endpoint
end
end
setup tags do
- :ok = Ecto.Adapters.SQL.Sandbox.checkout(RealEstate.Repo)
+ :ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo)
unless tags[:async] do
- Ecto.Adapters.SQL.Sandbox.mode(RealEstate.Repo, {:shared, self()})
+ Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()})
end
:ok
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index e115d8f..479ae8d 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -1,4 +1,4 @@
-defmodule RealEstateWeb.ConnCase do
+defmodule Bones73kWeb.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 RealEstateWeb.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 RealEstateWeb.ConnCase, async: true`, although
+ by setting `use Bones73kWeb.ConnCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -22,20 +22,20 @@ defmodule RealEstateWeb.ConnCase do
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
- import RealEstateWeb.ConnCase
+ import Bones73kWeb.ConnCase
- alias RealEstateWeb.Router.Helpers, as: Routes
+ alias Bones73kWeb.Router.Helpers, as: Routes
# The default endpoint for testing
- @endpoint RealEstateWeb.Endpoint
+ @endpoint Bones73kWeb.Endpoint
end
end
setup tags do
- :ok = Ecto.Adapters.SQL.Sandbox.checkout(RealEstate.Repo)
+ :ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo)
unless tags[:async] do
- Ecto.Adapters.SQL.Sandbox.mode(RealEstate.Repo, {:shared, self()})
+ Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()})
end
{:ok, conn: Phoenix.ConnTest.build_conn()}
@@ -50,7 +50,7 @@ defmodule RealEstateWeb.ConnCase do
test context.
"""
def register_and_log_in_user(%{conn: conn}) do
- user = RealEstate.AccountsFixtures.user_fixture()
+ user = Bones73k.AccountsFixtures.user_fixture()
%{conn: log_in_user(conn, user), user: user}
end
@@ -60,7 +60,7 @@ defmodule RealEstateWeb.ConnCase do
It returns an updated `conn`.
"""
def log_in_user(conn, user) do
- token = RealEstate.Accounts.generate_user_session_token(user)
+ token = Bones73k.Accounts.generate_user_session_token(user)
conn
|> Phoenix.ConnTest.init_test_session(%{})
diff --git a/test/support/data_case.ex b/test/support/data_case.ex
index 6a41fe9..9979302 100644
--- a/test/support/data_case.ex
+++ b/test/support/data_case.ex
@@ -1,4 +1,4 @@
-defmodule RealEstate.DataCase do
+defmodule Bones73k.DataCase do
@moduledoc """
This module defines the setup for tests requiring
access to the application's data layer.
@@ -10,7 +10,7 @@ defmodule RealEstate.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 RealEstate.DataCase, async: true`, although
+ by setting `use Bones73k.DataCase, async: true`, although
this option is not recommended for other databases.
"""
@@ -18,20 +18,20 @@ defmodule RealEstate.DataCase do
using do
quote do
- alias RealEstate.Repo
+ alias Bones73k.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
- import RealEstate.DataCase
+ import Bones73k.DataCase
end
end
setup tags do
- :ok = Ecto.Adapters.SQL.Sandbox.checkout(RealEstate.Repo)
+ :ok = Ecto.Adapters.SQL.Sandbox.checkout(Bones73k.Repo)
unless tags[:async] do
- Ecto.Adapters.SQL.Sandbox.mode(RealEstate.Repo, {:shared, self()})
+ Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, {:shared, self()})
end
:ok
diff --git a/test/support/fixtures/accounts_fixtures.ex b/test/support/fixtures/accounts_fixtures.ex
index 79c2c43..6320074 100644
--- a/test/support/fixtures/accounts_fixtures.ex
+++ b/test/support/fixtures/accounts_fixtures.ex
@@ -1,7 +1,7 @@
-defmodule RealEstate.AccountsFixtures do
+defmodule Bones73k.AccountsFixtures do
@moduledoc """
This module defines test helpers for creating
- entities via the `RealEstate.Accounts` context.
+ entities via the `Bones73k.Accounts` context.
"""
def unique_user_email, do: "user#{System.unique_integer()}@example.com"
@@ -14,7 +14,7 @@ defmodule RealEstate.AccountsFixtures do
email: unique_user_email(),
password: valid_user_password()
})
- |> RealEstate.Accounts.register_user()
+ |> Bones73k.Accounts.register_user()
user
end
@@ -26,7 +26,7 @@ defmodule RealEstate.AccountsFixtures do
email: unique_user_email(),
password: valid_user_password()
})
- |> RealEstate.Accounts.register_admin()
+ |> Bones73k.Accounts.register_admin()
user
end
diff --git a/test/test_helper.exs b/test/test_helper.exs
index 50aadae..d556404 100644
--- a/test/test_helper.exs
+++ b/test/test_helper.exs
@@ -1,2 +1,2 @@
ExUnit.start()
-Ecto.Adapters.SQL.Sandbox.mode(RealEstate.Repo, :manual)
+Ecto.Adapters.SQL.Sandbox.mode(Bones73k.Repo, :manual)