Skip to content

Commit

Permalink
updates for elixir 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Pallen committed Jun 10, 2021
1 parent 939764f commit e398b54
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 78 deletions.
2 changes: 1 addition & 1 deletion lib/mix/tasks/coh.gen.controllers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ defmodule Mix.Tasks.Coh.Gen.Controllers do
web_base = opts[:web_module] || base <> "Web"

binding =
Enum.into(
Keyword.merge(
[
base: base,
web_base: web_base,
Expand Down
21 changes: 13 additions & 8 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Coherence.Mixfile do
def application do
[
mod: {Coherence, []},
applications: [
extra_applications: [
:logger,
:comeonin,
:ecto,
Expand All @@ -36,13 +36,18 @@ defmodule Coherence.Mixfile do
:tzdata,
:plug,
:phoenix,
:phoenix_html
:phoenix_html,
:ecto_sql,
:timex,
:crypto,
:eex,
:plug
]
]
end

defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
defp elixirc_paths(_), do: ["lib", "web"]
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

defp deps do
[
Expand All @@ -56,12 +61,12 @@ defmodule Coherence.Mixfile do
{:phoenix_swoosh, "~> 0.2"},
{:timex, "~> 3.6"},
{:floki, "~> 0.19", only: :test},
{:ex_doc, "~> 0.18.0", only: :dev},
{:ex_doc, "~> 0.24.0", only: :dev},
{:earmark, "~> 1.2", only: :dev, override: true},
{:postgrex, ">= 0.0.0", only: :test},
{:dialyxir, "~> 0.5", only: [:dev], runtime: false},
{:credo, "~> 0.8", only: [:dev, :test]},
{:plug, "~> 1.6"},
{:dialyxir, "~> 1.1", only: [:dev], runtime: false},
{:credo, "~> 1.5", only: [:dev, :test]},
{:plug, "~> 1.11"},
{:jason, "~> 1.0"}
]
end
Expand Down
72 changes: 38 additions & 34 deletions mix.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<p class="alert alert-danger" role="alert"><%%= get_flash(@conn, :error) %></p>

<main role="main">
<%%= render @view_module, @view_template, assigns %>
<%%= @inner_content %>
</main>

</div> <!-- /container -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<title><%%= @email.subject %></title>
</head>
<body>
<%%= render @view_module, @view_template, assigns %>
<%%= @inner_content %>
</body>
</html>
2 changes: 1 addition & 1 deletion test/schema_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ defmodule CoherenceTest.Schema do
assert cs.errors == [
password:
{"should be at least %{count} character(s)",
[count: 4, validation: :length, min: 4]}
[{:count, 4}, {:validation, :length}, {:kind, :min}, {:type, :string}]}
]
end

Expand Down
4 changes: 3 additions & 1 deletion test/support/conn_case.exs → test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ defmodule TestCoherence.ConnCase do
using do
quote do
# Import conveniences for testing with connections
use Phoenix.ConnTest
import Plug.Conn
import Phoenix.ConnTest
import TestCoherence.ConnCase

alias TestCoherence.Repo
import Ecto
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions test/support/gettext.exs → test/support/gettext.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,5 @@ defmodule TestCoherenceWeb.Gettext do
See the [Gettext Docs](http://hexdocs.pm/gettext) for detailed usage.
"""

@dialyzer [
{:nowarn_function, "MACRO-dgettext": 3},
{:nowarn_function, "MACRO-dgettext": 4},
{:nowarn_function, "MACRO-dngettext": 5},
{:nowarn_function, "MACRO-dngettext": 6},
{:nowarn_function, "MACRO-ngettext_noop": 3}
]
use Gettext, otp_app: :coherence
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions test/support/schema.exs → test/support/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule TestCoherence.User do
model
|> cast(
params,
~w(password password_confirmation reset_password_token reset_password_sent_at)
~w(password password_confirmation reset_password_token reset_password_sent_at)a
)
|> validate_coherence_password_reset(params)
end
Expand Down Expand Up @@ -63,7 +63,7 @@ defmodule TestCoherence.Invitation do

def changeset(model, params \\ %{}) do
model
|> cast(params, ~w(name email token))
|> cast(params, ~w(name email token)a)
|> validate_required([:name, :email])
|> unique_constraint(:email)
|> validate_format(:email, ~r/@/)
Expand Down Expand Up @@ -98,7 +98,7 @@ defmodule TestCoherence.Account do
model
|> cast(
params,
~w(password password_confirmation reset_password_token reset_password_sent_at)
~w(password password_confirmation reset_password_token reset_password_sent_at)a
)
|> validate_coherence_password_reset(params)
end
Expand Down Expand Up @@ -134,7 +134,7 @@ defmodule TestCoherence.Coherence.User do
model
|> cast(
params,
~w(password password_confirmation reset_password_token reset_password_sent_at)
~w(password password_confirmation reset_password_token reset_password_sent_at)a
)
|> validate_coherence_password_reset(params)
end
Expand All @@ -155,7 +155,7 @@ defmodule TestCoherence.Coherence.Invitation do

def changeset(model, params \\ %{}) do
model
|> cast(params, ~w(name email token))
|> cast(params, ~w(name email token)a)
|> validate_required([:name, :email])
|> unique_constraint(:email)
|> validate_format(:email, ~r/@/)
Expand Down Expand Up @@ -194,7 +194,7 @@ defmodule TestCoherence.Coherence.Account do
model
|> cast(
params,
~w(password password_confirmation reset_password_token reset_password_sent_at)
~w(password password_confirmation reset_password_token reset_password_sent_at)a
)
|> validate_coherence_password_reset(params)
end
Expand All @@ -220,7 +220,7 @@ defmodule TestCoherence.Coherence.Rememberable do

def changeset(model, params \\ %{}) do
model
|> cast(params, ~w(series_hash token_hash token_created_at user_id))
|> cast(params, ~w(series_hash token_hash token_created_at user_id)a)
|> validate_required(~w(series_hash token_hash token_created_at user_id)a)
end

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions test/support/views.exs → test/support/views.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ defmodule TestCoherenceWeb.ErrorView do
def render("500.html", _changeset), do: "500.html"
def render("400.html", _changeset), do: "400.html"
end

defmodule TestCoherenceWeb.Coherence.RegistrationView do
use TestCoherenceWeb.Coherence, :view
def render("new.html", _params), do: "new registration"
def render("show.html", _params), do: "show registration"
def render("edit.html", _params), do: "edit registration"
end

defmodule TestCoherenceWeb.Coherence.PasswordView do
use TestCoherenceWeb.Coherence, :view
def render("new.html", _params), do: "new password"
def render("show.html", _params), do: "show password"
def render("edit.html", _params), do: "edit password"
end
File renamed without changes.
33 changes: 16 additions & 17 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
ExUnit.start()
Application.ensure_all_started(:coherence)

Code.require_file("./support/gettext.exs", __DIR__)
Code.require_file("./support/messages.exs", __DIR__)
Code.require_file("./support/view_helpers.exs", __DIR__)
Code.require_file("./support/web.exs", __DIR__)
Code.require_file("./support/dummy_controller.exs", __DIR__)
Code.require_file("./support/schema.exs", __DIR__)
Code.require_file("./support/repo.exs", __DIR__)
Code.require_file("./support/migrations.exs", __DIR__)
Code.require_file("./support/router.exs", __DIR__)
Code.require_file("./support/endpoint.exs", __DIR__)
Code.require_file("./support/model_case.exs", __DIR__)
Code.require_file("./support/conn_case.exs", __DIR__)
Code.require_file("./support/views.exs", __DIR__)
Code.require_file("./support/email.exs", __DIR__)
Code.require_file("./support/test_helpers.exs", __DIR__)
Code.require_file("./support/redirect.exs", __DIR__)
Code.require_file("./support/schemas.exs", __DIR__)
# Code.require_file("./support/gettext.exs", __DIR__)
# Code.require_file("./support/messages.exs", __DIR__)
# Code.require_file("./support/view_helpers.exs", __DIR__)
# Code.require_file("./support/web.exs", __DIR__)
# Code.require_file("./support/dummy_controller.exs", __DIR__)
# Code.require_file("./support/schema.exs", __DIR__)
# Code.require_file("./support/migrations.exs", __DIR__)
# Code.require_file("./support/router.exs", __DIR__)
# Code.require_file("./support/endpoint.exs", __DIR__)
# Code.require_file("./support/model_case.exs", __DIR__)
# Code.require_file("./support/conn_case.exs", __DIR__)
# Code.require_file("./support/views.exs", __DIR__)
# Code.require_file("./support/email.exs", __DIR__)
# Code.require_file("./support/test_helpers.exs", __DIR__)
# Code.require_file("./support/redirect.exs", __DIR__)
# Code.require_file("./support/schemas.exs", __DIR__)

defmodule Coherence.RepoSetup do
use ExUnit.CaseTemplate
Expand Down

0 comments on commit e398b54

Please sign in to comment.