Compare commits
7 Commits
f9b08222e1
...
6455e2710d
Author | SHA1 | Date | |
---|---|---|---|
6455e2710d | |||
6523b28aa2 | |||
bad1a23dfe | |||
e0ddefe1d7 | |||
5d6ecba9f7 | |||
a2d1ff9b89 | |||
34288a0070 |
14
.credo.exs
14
.credo.exs
@ -157,17 +157,17 @@
|
|||||||
#
|
#
|
||||||
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
|
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
|
||||||
#
|
#
|
||||||
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
|
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
|
||||||
{Credo.Check.Consistency.UnusedVariableNames, false},
|
{Credo.Check.Consistency.UnusedVariableNames, [force: :meaningful]},
|
||||||
{Credo.Check.Design.DuplicatedCode, false},
|
{Credo.Check.Design.DuplicatedCode, false},
|
||||||
{Credo.Check.Readability.AliasAs, false},
|
{Credo.Check.Readability.AliasAs, false},
|
||||||
{Credo.Check.Readability.BlockPipe, false},
|
{Credo.Check.Readability.BlockPipe, false},
|
||||||
{Credo.Check.Readability.ImplTrue, false},
|
{Credo.Check.Readability.ImplTrue, false},
|
||||||
{Credo.Check.Readability.MultiAlias, false},
|
{Credo.Check.Readability.MultiAlias, false},
|
||||||
{Credo.Check.Readability.SeparateAliasRequire, false},
|
{Credo.Check.Readability.SeparateAliasRequire, []},
|
||||||
{Credo.Check.Readability.SinglePipe, false},
|
{Credo.Check.Readability.SinglePipe, false},
|
||||||
{Credo.Check.Readability.Specs, false},
|
{Credo.Check.Readability.Specs, false},
|
||||||
{Credo.Check.Readability.StrictModuleLayout, false},
|
{Credo.Check.Readability.StrictModuleLayout, []},
|
||||||
{Credo.Check.Readability.WithCustomTaggedTuple, false},
|
{Credo.Check.Readability.WithCustomTaggedTuple, false},
|
||||||
{Credo.Check.Refactor.ABCSize, false},
|
{Credo.Check.Refactor.ABCSize, false},
|
||||||
{Credo.Check.Refactor.AppendSingleItem, false},
|
{Credo.Check.Refactor.AppendSingleItem, false},
|
||||||
@ -176,9 +176,9 @@
|
|||||||
{Credo.Check.Refactor.NegatedIsNil, false},
|
{Credo.Check.Refactor.NegatedIsNil, false},
|
||||||
{Credo.Check.Refactor.PipeChainStart, false},
|
{Credo.Check.Refactor.PipeChainStart, false},
|
||||||
{Credo.Check.Refactor.VariableRebinding, false},
|
{Credo.Check.Refactor.VariableRebinding, false},
|
||||||
{Credo.Check.Warning.LeakyEnvironment, false},
|
{Credo.Check.Warning.LeakyEnvironment, []},
|
||||||
{Credo.Check.Warning.MapGetUnsafePass, false},
|
{Credo.Check.Warning.MapGetUnsafePass, []},
|
||||||
{Credo.Check.Warning.UnsafeToAtom, false}
|
{Credo.Check.Warning.UnsafeToAtom, []}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Custom checks can be created using `mix credo.gen.check`.
|
# Custom checks can be created using `mix credo.gen.check`.
|
||||||
|
@ -77,7 +77,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: cache
|
- name: cache
|
||||||
host:
|
host:
|
||||||
path: /tmp/drone-cache
|
path: /run/media/default/ssdsrv/gitea/drone-cache
|
||||||
- name: docker_sock
|
- name: docker_sock
|
||||||
host:
|
host:
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# v0.4.1
|
||||||
|
- Fix button and tag text wrapping
|
||||||
|
- Code quality fixes
|
||||||
|
|
||||||
# v0.4.0
|
# v0.4.0
|
||||||
- Make tables sortable
|
- Make tables sortable
|
||||||
- Add link to changelog from version number
|
- Add link to changelog from version number
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
|
@apply inline-block break-all min-w-4;
|
||||||
@apply focus:outline-none px-4 py-2 rounded-lg;
|
@apply focus:outline-none px-4 py-2 rounded-lg;
|
||||||
@apply shadow-sm focus:shadow-lg;
|
@apply shadow-sm focus:shadow-lg;
|
||||||
@apply transition-all duration-300 ease-in-out;
|
@apply transition-all duration-300 ease-in-out;
|
||||||
@ -51,6 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
|
@apply inline-block break-all min-w-4;
|
||||||
@apply hover:underline;
|
@apply hover:underline;
|
||||||
@apply transition-colors duration-500 ease-in-out;
|
@apply transition-colors duration-500 ease-in-out;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,20 @@ module.exports = {
|
|||||||
128: '32rem',
|
128: '32rem',
|
||||||
192: '48rem',
|
192: '48rem',
|
||||||
256: '64rem'
|
256: '64rem'
|
||||||
|
},
|
||||||
|
minWidth: {
|
||||||
|
4: '1rem',
|
||||||
|
8: '2rem',
|
||||||
|
12: '3rem',
|
||||||
|
16: '4rem',
|
||||||
|
20: '8rem'
|
||||||
|
},
|
||||||
|
maxWidth: {
|
||||||
|
4: '1rem',
|
||||||
|
8: '2rem',
|
||||||
|
12: '3rem',
|
||||||
|
16: '4rem',
|
||||||
|
20: '8rem'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -196,7 +196,7 @@ defmodule Cannery.Accounts do
|
|||||||
{:ok, _} <- Repo.transaction(user_email_multi(user, email, context)) do
|
{:ok, _} <- Repo.transaction(user_email_multi(user, email, context)) do
|
||||||
:ok
|
:ok
|
||||||
else
|
else
|
||||||
_ -> :error
|
_error_tuple -> :error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ defmodule Cannery.Accounts do
|
|||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, %{user: user}} -> {:ok, user}
|
{:ok, %{user: user}} -> {:ok, user}
|
||||||
{:error, :user, changeset, _} -> {:error, changeset}
|
{:error, :user, changeset, _changes_so_far} -> {:error, changeset}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ defmodule Cannery.Accounts do
|
|||||||
{:ok, %{user: user}} <- Repo.transaction(confirm_user_multi(user)) do
|
{:ok, %{user: user}} <- Repo.transaction(confirm_user_multi(user)) do
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
else
|
else
|
||||||
_ -> :error
|
_error_tuple -> :error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ defmodule Cannery.Accounts do
|
|||||||
%User{} = user <- Repo.one(query) do
|
%User{} = user <- Repo.one(query) do
|
||||||
user
|
user
|
||||||
else
|
else
|
||||||
_ -> nil
|
_error_tuple -> nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ defmodule Cannery.Accounts do
|
|||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, %{user: user}} -> {:ok, user}
|
{:ok, %{user: user}} -> {:ok, user}
|
||||||
{:error, :user, changeset, _} -> {:error, changeset}
|
{:error, :user, changeset, _changes_so_far} -> {:error, changeset}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -171,7 +171,7 @@ defmodule Cannery.Accounts.User do
|
|||||||
Bcrypt.verify_pass(password, hashed_password)
|
Bcrypt.verify_pass(password, hashed_password)
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_password?(_, _) do
|
def valid_password?(_invalid_user, _invalid_password) do
|
||||||
Bcrypt.no_user_verify()
|
Bcrypt.no_user_verify()
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -308,7 +308,7 @@ defmodule Cannery.Ammo do
|
|||||||
def get_used_count(%AmmoGroup{} = ammo_group) do
|
def get_used_count(%AmmoGroup{} = ammo_group) do
|
||||||
ammo_group
|
ammo_group
|
||||||
|> Repo.preload(:shot_groups)
|
|> Repo.preload(:shot_groups)
|
||||||
|> Map.get(:shot_groups)
|
|> Map.fetch!(:shot_groups)
|
||||||
|> Enum.map(fn %{count: count} -> count end)
|
|> Enum.map(fn %{count: count} -> count end)
|
||||||
|> Enum.sum()
|
|> Enum.sum()
|
||||||
end
|
end
|
||||||
|
@ -215,7 +215,7 @@ defmodule Cannery.Containers do
|
|||||||
def get_container_rounds!(%Container{} = container) do
|
def get_container_rounds!(%Container{} = container) do
|
||||||
container
|
container
|
||||||
|> Repo.preload(:ammo_groups)
|
|> Repo.preload(:ammo_groups)
|
||||||
|> Map.get(:ammo_groups)
|
|> Map.fetch!(:ammo_groups)
|
||||||
|> Enum.map(fn %{count: count} -> count end)
|
|> Enum.map(fn %{count: count} -> count end)
|
||||||
|> Enum.sum()
|
|> Enum.sum()
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ defmodule Cannery.Release do
|
|||||||
|
|
||||||
def rollback(repo, version) do
|
def rollback(repo, version) do
|
||||||
load_app()
|
load_app()
|
||||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
{:ok, _fun, _opts} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp load_app do
|
defp load_app do
|
||||||
@ -20,7 +20,7 @@ defmodule Cannery.Release do
|
|||||||
load_app()
|
load_app()
|
||||||
|
|
||||||
for repo <- Application.fetch_env!(@app, :ecto_repos) do
|
for repo <- Application.fetch_env!(@app, :ecto_repos) do
|
||||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
{:ok, _fun, _opts} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,11 +6,11 @@ defmodule Cannery.Repo.Migrator do
|
|||||||
use GenServer
|
use GenServer
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
def start_link(_) do
|
def start_link(_opts) do
|
||||||
GenServer.start_link(__MODULE__, [], [])
|
GenServer.start_link(__MODULE__, [], [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def init(_) do
|
def init(_opts) do
|
||||||
migrate!()
|
migrate!()
|
||||||
{:ok, nil}
|
{:ok, nil}
|
||||||
end
|
end
|
||||||
|
@ -71,6 +71,7 @@ defmodule CanneryWeb do
|
|||||||
quote do
|
quote do
|
||||||
use Phoenix.Router
|
use Phoenix.Router
|
||||||
|
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import Phoenix.Controller
|
import Phoenix.Controller
|
||||||
import Phoenix.LiveView.Router
|
import Phoenix.LiveView.Router
|
||||||
@ -79,7 +80,9 @@ defmodule CanneryWeb do
|
|||||||
|
|
||||||
def channel do
|
def channel do
|
||||||
quote do
|
quote do
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
use Phoenix.Channel
|
use Phoenix.Channel
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
import CanneryWeb.Gettext
|
import CanneryWeb.Gettext
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -87,14 +90,18 @@ defmodule CanneryWeb do
|
|||||||
defp view_helpers do
|
defp view_helpers do
|
||||||
quote do
|
quote do
|
||||||
# Use all HTML functionality (forms, tags, etc)
|
# Use all HTML functionality (forms, tags, etc)
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
use Phoenix.HTML
|
use Phoenix.HTML
|
||||||
|
|
||||||
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
|
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
import Phoenix.LiveView.Helpers
|
import Phoenix.LiveView.Helpers
|
||||||
|
|
||||||
# Import basic rendering functionality (render, render_layout, etc)
|
# Import basic rendering functionality (render, render_layout, etc)
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
import Phoenix.View
|
import Phoenix.View
|
||||||
|
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
import CanneryWeb.{ErrorHelpers, Gettext, LiveHelpers, ViewHelpers}
|
import CanneryWeb.{ErrorHelpers, Gettext, LiveHelpers, ViewHelpers}
|
||||||
alias CanneryWeb.Router.Helpers, as: Routes
|
alias CanneryWeb.Router.Helpers, as: Routes
|
||||||
end
|
end
|
||||||
|
@ -14,11 +14,11 @@ defmodule CanneryWeb.Components.ContainerCard do
|
|||||||
~H"""
|
~H"""
|
||||||
<div
|
<div
|
||||||
id={"container-#{@container.id}"}
|
id={"container-#{@container.id}"}
|
||||||
class="mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center space-y-4
|
class="overflow-hidden max-w-full mx-4 my-2 px-8 py-4 flex flex-col justify-center items-center space-y-4
|
||||||
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
|
||||||
transition-all duration-300 ease-in-out"
|
transition-all duration-300 ease-in-out"
|
||||||
>
|
>
|
||||||
<div class="mb-4 flex flex-col justify-center items-center space-y-2">
|
<div class="max-w-full mb-4 flex flex-col justify-center items-center space-y-2">
|
||||||
<%= live_redirect to: Routes.container_show_path(Endpoint, :show, @container),
|
<%= live_redirect to: Routes.container_show_path(Endpoint, :show, @container),
|
||||||
class: "link" do %>
|
class: "link" do %>
|
||||||
<h1 class="px-4 py-2 rounded-lg title text-xl">
|
<h1 class="px-4 py-2 rounded-lg title text-xl">
|
||||||
|
@ -22,7 +22,7 @@ defmodule CanneryWeb.Components.TagCard do
|
|||||||
def simple_tag_card(assigns) do
|
def simple_tag_card(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<h1
|
<h1
|
||||||
class="mx-2 my-1 px-4 py-2 rounded-lg title text-xl"
|
class="inline-block break-all mx-2 my-1 px-4 py-2 rounded-lg title text-xl"
|
||||||
style={"color: #{@tag.text_color}; background-color: #{@tag.bg_color}"}
|
style={"color: #{@tag.text_color}; background-color: #{@tag.bg_color}"}
|
||||||
>
|
>
|
||||||
<%= @tag.name %>
|
<%= @tag.name %>
|
||||||
|
@ -121,9 +121,10 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
|||||||
|
|
||||||
{staged,
|
{staged,
|
||||||
~H"""
|
~H"""
|
||||||
|
<div class="min-w-20 py-2 px-4 h-full flex flex-col justify-center items-center">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-primary"
|
class="mx-2 my-1 btn btn-primary"
|
||||||
phx-click="toggle_staged"
|
phx-click="toggle_staged"
|
||||||
phx-value-ammo_group_id={ammo_group.id}
|
phx-value-ammo_group_id={ammo_group.id}
|
||||||
>
|
>
|
||||||
@ -132,8 +133,9 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
|||||||
|
|
||||||
<%= live_patch(dgettext("actions", "Record shots"),
|
<%= live_patch(dgettext("actions", "Record shots"),
|
||||||
to: Routes.ammo_group_index_path(Endpoint, :add_shot_group, ammo_group),
|
to: Routes.ammo_group_index_path(Endpoint, :add_shot_group, ammo_group),
|
||||||
class: "btn btn-primary"
|
class: "mx-2 my-1 btn btn-primary"
|
||||||
) %>
|
) %>
|
||||||
|
</div>
|
||||||
"""}
|
"""}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,11 +176,17 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
|||||||
defp get_value_for_key("container", %{container: nil}), do: {nil, nil}
|
defp get_value_for_key("container", %{container: nil}), do: {nil, nil}
|
||||||
|
|
||||||
defp get_value_for_key("container", %{container: %{name: container_name}} = ammo_group) do
|
defp get_value_for_key("container", %{container: %{name: container_name}} = ammo_group) do
|
||||||
|
assigns = %{ammo_group: ammo_group}
|
||||||
|
|
||||||
{container_name,
|
{container_name,
|
||||||
live_patch(container_name,
|
~H"""
|
||||||
to: Routes.ammo_group_index_path(Endpoint, :move, ammo_group),
|
<div class="min-w-20 py-2 px-4 h-full space-x-4 flex justify-center items-center">
|
||||||
|
<%= live_patch(@ammo_group.container.name,
|
||||||
|
to: Routes.ammo_group_index_path(Endpoint, :move, @ammo_group),
|
||||||
class: "btn btn-primary"
|
class: "btn btn-primary"
|
||||||
)}
|
) %>
|
||||||
|
</div>
|
||||||
|
"""}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_value_for_key(key, ammo_group),
|
defp get_value_for_key(key, ammo_group),
|
||||||
|
@ -44,7 +44,7 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
|
|||||||
@impl true
|
@impl true
|
||||||
def handle_event(
|
def handle_event(
|
||||||
"delete",
|
"delete",
|
||||||
_,
|
_params,
|
||||||
%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket
|
%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket
|
||||||
) do
|
) do
|
||||||
ammo_group |> Ammo.delete_ammo_group!(current_user)
|
ammo_group |> Ammo.delete_ammo_group!(current_user)
|
||||||
@ -58,7 +58,7 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
|
|||||||
@impl true
|
@impl true
|
||||||
def handle_event(
|
def handle_event(
|
||||||
"toggle_staged",
|
"toggle_staged",
|
||||||
_,
|
_params,
|
||||||
%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket
|
%{assigns: %{ammo_group: ammo_group, current_user: current_user}} = socket
|
||||||
) do
|
) do
|
||||||
{:ok, ammo_group} =
|
{:ok, ammo_group} =
|
||||||
|
@ -14,7 +14,7 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_params(%{"id" => id}, _, %{assigns: %{current_user: current_user}} = socket) do
|
def handle_params(%{"id" => id}, _params, %{assigns: %{current_user: current_user}} = socket) do
|
||||||
ammo_type = Ammo.get_ammo_type!(id, current_user)
|
ammo_type = Ammo.get_ammo_type!(id, current_user)
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
@ -32,7 +32,7 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
|||||||
@impl true
|
@impl true
|
||||||
def handle_event(
|
def handle_event(
|
||||||
"delete",
|
"delete",
|
||||||
_,
|
_params,
|
||||||
%{assigns: %{ammo_type: ammo_type, current_user: current_user}} = socket
|
%{assigns: %{ammo_type: ammo_type, current_user: current_user}} = socket
|
||||||
) do
|
) do
|
||||||
%{name: ammo_type_name} = ammo_type |> Ammo.delete_ammo_type!(current_user)
|
%{name: ammo_type_name} = ammo_type |> Ammo.delete_ammo_type!(current_user)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
) %>
|
) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="flex flex-row flex-wrap justify-center items-center">
|
<div class="max-w-full flex flex-row flex-wrap justify-center items-center">
|
||||||
<%= for container <- @containers do %>
|
<%= for container <- @containers do %>
|
||||||
<.container_card container={container}>
|
<.container_card container={container}>
|
||||||
<:tag_actions>
|
<:tag_actions>
|
||||||
|
@ -18,7 +18,7 @@ defmodule CanneryWeb.ContainerLive.Show do
|
|||||||
@impl true
|
@impl true
|
||||||
def handle_params(
|
def handle_params(
|
||||||
%{"id" => id},
|
%{"id" => id},
|
||||||
_,
|
_session,
|
||||||
%{assigns: %{current_user: current_user}} = socket
|
%{assigns: %{current_user: current_user}} = socket
|
||||||
) do
|
) do
|
||||||
{:noreply, socket |> render_container(id, current_user)}
|
{:noreply, socket |> render_container(id, current_user)}
|
||||||
@ -53,7 +53,7 @@ defmodule CanneryWeb.ContainerLive.Show do
|
|||||||
@impl true
|
@impl true
|
||||||
def handle_event(
|
def handle_event(
|
||||||
"delete_container",
|
"delete_container",
|
||||||
_,
|
_params,
|
||||||
%{assigns: %{container: container, current_user: current_user}} = socket
|
%{assigns: %{container: container, current_user: current_user}} = socket
|
||||||
) do
|
) do
|
||||||
socket =
|
socket =
|
||||||
|
@ -29,7 +29,7 @@ defmodule CanneryWeb.HomeLive do
|
|||||||
%{^query => vsn} ->
|
%{^query => vsn} ->
|
||||||
{:noreply, redirect(socket, external: "https://hexdocs.pm/#{query}/#{vsn}")}
|
{:noreply, redirect(socket, external: "https://hexdocs.pm/#{query}/#{vsn}")}
|
||||||
|
|
||||||
_ ->
|
_no_query ->
|
||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> put_flash(:error, "No dependencies found matching \"#{query}\"")
|
|> put_flash(:error, "No dependencies found matching \"#{query}\"")
|
||||||
@ -133,7 +133,7 @@ defmodule CanneryWeb.HomeLive do
|
|||||||
to: "https://gitea.bubbletea.dev/shibao/cannery/src/branch/stable/CHANGELOG.md",
|
to: "https://gitea.bubbletea.dev/shibao/cannery/src/branch/stable/CHANGELOG.md",
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
rel: "noopener noreferrer" do %>
|
rel: "noopener noreferrer" do %>
|
||||||
<p>0.4.0</p>
|
<p>0.4.1</p>
|
||||||
<i class="fas fa-md fa-info-circle"></i>
|
<i class="fas fa-md fa-info-circle"></i>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
@ -119,7 +119,7 @@ defmodule CanneryWeb.InviteLive.Index do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_event("copy_to_clipboard", _, socket) do
|
def handle_event("copy_to_clipboard", _params, socket) do
|
||||||
prompt = dgettext("prompts", "Copied to clipboard")
|
prompt = dgettext("prompts", "Copied to clipboard")
|
||||||
{:noreply, socket |> put_flash(:info, prompt)}
|
{:noreply, socket |> put_flash(:info, prompt)}
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,6 @@ defmodule CanneryWeb.EmailView do
|
|||||||
@moduledoc """
|
@moduledoc """
|
||||||
A view for email-related helper functions
|
A view for email-related helper functions
|
||||||
"""
|
"""
|
||||||
alias CanneryWeb.{Endpoint, HomeLive}
|
|
||||||
|
|
||||||
use CanneryWeb, :view
|
use CanneryWeb, :view
|
||||||
|
alias CanneryWeb.{Endpoint, HomeLive}
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ defmodule CanneryWeb.ErrorView do
|
|||||||
case error_path do
|
case error_path do
|
||||||
"404.html" -> dgettext("errors", "Not found")
|
"404.html" -> dgettext("errors", "Not found")
|
||||||
"401.html" -> dgettext("errors", "Unauthorized")
|
"401.html" -> dgettext("errors", "Unauthorized")
|
||||||
_ -> dgettext("errors", "Internal Server Error")
|
_other_template -> dgettext("errors", "Internal Server Error")
|
||||||
end
|
end
|
||||||
|
|
||||||
render("error.html", %{error_string: error_string})
|
render("error.html", %{error_string: error_string})
|
||||||
|
2
mix.exs
2
mix.exs
@ -4,7 +4,7 @@ defmodule Cannery.MixProject do
|
|||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :cannery,
|
app: :cannery,
|
||||||
version: "0.4.0",
|
version: "0.4.1",
|
||||||
elixir: "~> 1.12",
|
elixir: "~> 1.12",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
compilers: [:gettext] ++ Mix.compilers(),
|
compilers: [:gettext] ++ Mix.compilers(),
|
||||||
|
@ -160,7 +160,7 @@ msgid "Why not get some ready to shoot?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
#: lib/cannery_web/live/ammo_group_live/index.ex:133
|
#: lib/cannery_web/live/ammo_group_live/index.ex:134
|
||||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:86
|
#: lib/cannery_web/live/ammo_group_live/show.html.heex:86
|
||||||
#: lib/cannery_web/live/range_live/index.html.heex:36
|
#: lib/cannery_web/live/range_live/index.html.heex:36
|
||||||
msgid "Record shots"
|
msgid "Record shots"
|
||||||
|
@ -689,12 +689,12 @@ msgid "New password"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
#: lib/cannery_web/live/ammo_group_live/index.ex:130
|
#: lib/cannery_web/live/ammo_group_live/index.ex:131
|
||||||
msgid "Stage"
|
msgid "Stage"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
#: lib/cannery_web/live/ammo_group_live/index.ex:130
|
#: lib/cannery_web/live/ammo_group_live/index.ex:131
|
||||||
msgid "Unstage"
|
msgid "Unstage"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ msgid "Are you sure you want to delete the invite for %{name}?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
#: lib/cannery_web/live/ammo_group_live/index.ex:165
|
#: lib/cannery_web/live/ammo_group_live/index.ex:167
|
||||||
#: lib/cannery_web/live/ammo_group_live/show.html.heex:66
|
#: lib/cannery_web/live/ammo_group_live/show.html.heex:66
|
||||||
#: lib/cannery_web/live/ammo_type_live/index.ex:130
|
#: lib/cannery_web/live/ammo_type_live/index.ex:130
|
||||||
msgid "Are you sure you want to delete this ammo?"
|
msgid "Are you sure you want to delete this ammo?"
|
||||||
|
@ -304,9 +304,9 @@ defmodule Cannery.AccountsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "deletes all tokens for the given user", %{user: user} do
|
test "deletes all tokens for the given user", %{user: user} do
|
||||||
_ = Accounts.generate_user_session_token(user)
|
_token = Accounts.generate_user_session_token(user)
|
||||||
|
|
||||||
{:ok, _} =
|
{:ok, _user} =
|
||||||
Accounts.update_user_password(user, valid_user_password(), %{
|
Accounts.update_user_password(user, valid_user_password(), %{
|
||||||
"password" => "new valid password"
|
"password" => "new valid password"
|
||||||
})
|
})
|
||||||
@ -501,8 +501,8 @@ defmodule Cannery.AccountsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "deletes all tokens for the given user", %{user: user} do
|
test "deletes all tokens for the given user", %{user: user} do
|
||||||
_ = Accounts.generate_user_session_token(user)
|
_token = Accounts.generate_user_session_token(user)
|
||||||
{:ok, _} = Accounts.reset_user_password(user, %{"password" => "new valid password"})
|
{:ok, _user} = Accounts.reset_user_password(user, %{"password" => "new valid password"})
|
||||||
refute Repo.get_by(UserToken, user_id: user.id)
|
refute Repo.get_by(UserToken, user_id: user.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -116,7 +116,7 @@ defmodule CanneryWeb.UserAuthTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "does not authenticate if data is missing", %{conn: conn, current_user: current_user} do
|
test "does not authenticate if data is missing", %{conn: conn, current_user: current_user} do
|
||||||
_ = Accounts.generate_user_session_token(current_user)
|
_token = Accounts.generate_user_session_token(current_user)
|
||||||
conn = UserAuth.fetch_current_user(conn, [])
|
conn = UserAuth.fetch_current_user(conn, [])
|
||||||
refute get_session(conn, :user_token)
|
refute get_session(conn, :user_token)
|
||||||
refute conn.assigns.current_user
|
refute conn.assigns.current_user
|
||||||
|
@ -5,8 +5,7 @@ defmodule CanneryWeb.UserConfirmationControllerTest do
|
|||||||
|
|
||||||
use CanneryWeb.ConnCase, async: true
|
use CanneryWeb.ConnCase, async: true
|
||||||
import CanneryWeb.Gettext
|
import CanneryWeb.Gettext
|
||||||
alias Cannery.Accounts
|
alias Cannery.{Accounts, Repo}
|
||||||
alias Cannery.Repo
|
|
||||||
|
|
||||||
@moduletag :user_confirmation_controller_test
|
@moduletag :user_confirmation_controller_test
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#ammo_group-form", ammo_group: @create_attrs)
|
|> form("#ammo_group-form", ammo_group: @create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -75,7 +75,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#ammo_group-form",
|
|> form("#ammo_group-form",
|
||||||
ammo_group: @create_attrs |> Map.put("multiplier", to_string(multiplier))
|
ammo_group: @create_attrs |> Map.put("multiplier", to_string(multiplier))
|
||||||
@ -135,7 +135,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "is invalid")
|
# |> render_change() =~ dgettext("errors", "is invalid")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#shot-group-form", shot_group: @shot_group_create_attrs)
|
|> form("#shot-group-form", shot_group: @shot_group_create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -158,7 +158,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#ammo_group-form", ammo_group: @update_attrs)
|
|> form("#ammo_group-form", ammo_group: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -204,7 +204,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
# |> form("#ammo_group-form", ammo_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
show_live
|
show_live
|
||||||
|> form("#ammo_group-form", ammo_group: @update_attrs)
|
|> form("#ammo_group-form", ammo_group: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -226,7 +226,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "is invalid")
|
# |> render_change() =~ dgettext("errors", "is invalid")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#shot-group-form", shot_group: @shot_group_create_attrs)
|
|> form("#shot-group-form", shot_group: @shot_group_create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -251,7 +251,7 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
|||||||
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "is invalid")
|
# |> render_change() =~ dgettext("errors", "is invalid")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#shot-group-form", shot_group: @shot_group_update_attrs)
|
|> form("#shot-group-form", shot_group: @shot_group_update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
@ -62,7 +62,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
|||||||
# |> form("#ammo_type-form", ammo_type: @invalid_attrs)
|
# |> form("#ammo_type-form", ammo_type: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#ammo_type-form", ammo_type: @create_attrs)
|
|> form("#ammo_type-form", ammo_type: @create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -86,7 +86,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
|||||||
# |> form("#ammo_type-form", ammo_type: @invalid_attrs)
|
# |> form("#ammo_type-form", ammo_type: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#ammo_type-form", ammo_type: @update_attrs)
|
|> form("#ammo_type-form", ammo_type: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -128,7 +128,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
|||||||
# |> form("#ammo_type-form", ammo_type: @invalid_attrs)
|
# |> form("#ammo_type-form", ammo_type: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
show_live
|
show_live
|
||||||
|> form("#ammo_type-form", ammo_type: @update_attrs)
|
|> form("#ammo_type-form", ammo_type: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
@ -52,7 +52,7 @@ defmodule CanneryWeb.ContainerLiveTest do
|
|||||||
# |> form("#container-form", container: @invalid_attrs)
|
# |> form("#container-form", container: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#container-form", container: @create_attrs)
|
|> form("#container-form", container: @create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -78,7 +78,7 @@ defmodule CanneryWeb.ContainerLiveTest do
|
|||||||
# |> form("#container-form", container: @invalid_attrs)
|
# |> form("#container-form", container: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#container-form", container: @update_attrs)
|
|> form("#container-form", container: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -123,7 +123,7 @@ defmodule CanneryWeb.ContainerLiveTest do
|
|||||||
# |> form("#container-form", container: @invalid_attrs)
|
# |> form("#container-form", container: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
show_live
|
show_live
|
||||||
|> form("#container-form", container: @update_attrs)
|
|> form("#container-form", container: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
@ -40,7 +40,7 @@ defmodule CanneryWeb.InviteLiveTest do
|
|||||||
# |> form("#invite-form", invite: @invalid_attrs)
|
# |> form("#invite-form", invite: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#invite-form", invite: @create_attrs)
|
|> form("#invite-form", invite: @create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -63,7 +63,7 @@ defmodule CanneryWeb.InviteLiveTest do
|
|||||||
# |> form("#invite-form", invite: @invalid_attrs)
|
# |> form("#invite-form", invite: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#invite-form", invite: @update_attrs)
|
|> form("#invite-form", invite: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
@ -49,7 +49,7 @@ defmodule CanneryWeb.RangeLiveTest do
|
|||||||
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "is invalid")
|
# |> render_change() =~ dgettext("errors", "is invalid")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#shot-group-form", shot_group: @create_attrs)
|
|> form("#shot-group-form", shot_group: @create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -71,7 +71,7 @@ defmodule CanneryWeb.RangeLiveTest do
|
|||||||
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
# |> form("#shot_group-form", shot_group: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "is invalid")
|
# |> render_change() =~ dgettext("errors", "is invalid")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#shot-group-form", shot_group: @update_attrs)
|
|> form("#shot-group-form", shot_group: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
@ -53,7 +53,7 @@ defmodule CanneryWeb.TagLiveTest do
|
|||||||
# |> form("#tag-form", tag: @invalid_attrs)
|
# |> form("#tag-form", tag: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#tag-form", tag: @create_attrs)
|
|> form("#tag-form", tag: @create_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
@ -75,7 +75,7 @@ defmodule CanneryWeb.TagLiveTest do
|
|||||||
# |> form("#tag-form", tag: @invalid_attrs)
|
# |> form("#tag-form", tag: @invalid_attrs)
|
||||||
# |> render_change() =~ dgettext("errors", "can't be blank")
|
# |> render_change() =~ dgettext("errors", "can't be blank")
|
||||||
|
|
||||||
{:ok, _, html} =
|
{:ok, _view, html} =
|
||||||
index_live
|
index_live
|
||||||
|> form("#tag-form", tag: @update_attrs)
|
|> form("#tag-form", tag: @update_attrs)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
@ -5,12 +5,11 @@ defmodule CanneryWeb.ErrorViewTest do
|
|||||||
|
|
||||||
use CanneryWeb.ConnCase, async: true
|
use CanneryWeb.ConnCase, async: true
|
||||||
import CanneryWeb.Gettext
|
import CanneryWeb.Gettext
|
||||||
|
|
||||||
@moduletag :error_view_test
|
|
||||||
|
|
||||||
# Bring render/3 and render_to_string/3 for testing custom views
|
# Bring render/3 and render_to_string/3 for testing custom views
|
||||||
import Phoenix.View
|
import Phoenix.View
|
||||||
|
|
||||||
|
@moduletag :error_view_test
|
||||||
|
|
||||||
test "renders 404.html" do
|
test "renders 404.html" do
|
||||||
assert render_to_string(CanneryWeb.ErrorView, "404.html", []) =~
|
assert render_to_string(CanneryWeb.ErrorView, "404.html", []) =~
|
||||||
dgettext("errors", "Not found")
|
dgettext("errors", "Not found")
|
||||||
|
@ -25,6 +25,7 @@ defmodule CanneryWeb.ConnCase do
|
|||||||
# Import conveniences for testing with connections
|
# Import conveniences for testing with connections
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import Phoenix.ConnTest
|
import Phoenix.ConnTest
|
||||||
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
import Cannery.Fixtures
|
import Cannery.Fixtures
|
||||||
import CanneryWeb.ConnCase
|
import CanneryWeb.ConnCase
|
||||||
|
|
||||||
|
@ -22,10 +22,8 @@ defmodule Cannery.DataCase do
|
|||||||
alias Cannery.Repo
|
alias Cannery.Repo
|
||||||
|
|
||||||
import Ecto
|
import Ecto
|
||||||
import Ecto.Changeset
|
import Ecto.{Changeset, Query}
|
||||||
import Ecto.Query
|
import Cannery.{DataCase, Fixtures}
|
||||||
import Cannery.DataCase
|
|
||||||
import Cannery.Fixtures
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ defmodule Cannery.DataCase do
|
|||||||
"""
|
"""
|
||||||
def errors_on(changeset) do
|
def errors_on(changeset) do
|
||||||
Ecto.Changeset.traverse_errors(changeset, fn {message, opts} ->
|
Ecto.Changeset.traverse_errors(changeset, fn {message, opts} ->
|
||||||
Regex.replace(~r"%{(\w+)}", message, fn _, key ->
|
Regex.replace(~r"%{(\w+)}", message, fn _content, key ->
|
||||||
opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string()
|
opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user