diff --git a/.credo.exs b/.credo.exs index 1db3d82..a7765a6 100644 --- a/.credo.exs +++ b/.credo.exs @@ -70,7 +70,6 @@ # set this value to 0 (zero). {Credo.Check.Design.TagTODO, exit_status: 2}, {Credo.Check.Design.TagFIXME}, - {Credo.Check.Readability.FunctionNames}, {Credo.Check.Readability.LargeNumbers}, {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80}, @@ -88,7 +87,6 @@ {Credo.Check.Readability.VariableNames}, {Credo.Check.Readability.Semicolons}, {Credo.Check.Readability.SpaceAfterCommas}, - {Credo.Check.Refactor.DoubleBooleanNegation}, {Credo.Check.Refactor.CondStatements}, {Credo.Check.Refactor.CyclomaticComplexity}, @@ -99,7 +97,6 @@ {Credo.Check.Refactor.Nesting}, {Credo.Check.Refactor.PipeChainStart}, {Credo.Check.Refactor.UnlessWithElse}, - {Credo.Check.Warning.BoolOperationOnSameValues}, {Credo.Check.Warning.IExPry}, {Credo.Check.Warning.IoInspect}, @@ -128,7 +125,7 @@ {Credo.Check.Warning.NameRedeclarationByAssignment, false}, {Credo.Check.Warning.NameRedeclarationByCase, false}, {Credo.Check.Warning.NameRedeclarationByDef, false}, - {Credo.Check.Warning.NameRedeclarationByFn, false}, + {Credo.Check.Warning.NameRedeclarationByFn, false} # Custom checks can be created using `mix credo.gen.check`. # diff --git a/.formatter.exs b/.formatter.exs index d3bbf13..8a6391c 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,20 +1,5 @@ [ - inputs: [ - "mix.exs", - "{config,lib,test,priv}/**/*.{ex,exs}" - ], - locals_without_parens: [ - # Formatter tests - assert_format: 2, - assert_format: 3, - assert_same: 1, - assert_same: 2, - - # Errors tests - assert_eval_raise: 3, - - # Mix tests - in_fixture: 2, - in_tmp: 2 - ] + import_deps: [:ecto, :phoenix], + inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"], + subdirectories: ["priv/*/migrations"] ] diff --git a/CHANGELOG.md b/CHANGELOG.md index 33ea0f8..4bc07a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Updates to Elixir, Erlang and deps - elixir 1.9.1 -- erlang 22.1 -- Circle CI config for elixir 1.9.1 + - erlang 22.1 + - Circle CI config for elixir 1.9.1 +- Phoenix v1.3 -> v1.4 + - Refactoring of several modules + - References: + - https://www.phoenixdiff.org/?source=1.3.0&target=1.4.3 + - https://github.com/phoenixframework/phoenix/blob/v1.4/CHANGELOG.md +- Ecto v2 -> v3 + - This upgrade includes the split into Ecto + Ecto_sql +- Comeonin v4 -> v5 + - Comeonin changed how dependencies works + - basically we removed comeonein deps and function calls and replaced it with BCrypt ones + - Reference: https://github.com/riverrun/comeonin/blob/master/UPGRADE_v5.md ## [1.0.0] - 2019-04-10 diff --git a/config/config.exs b/config/config.exs index 1f01188..8a8ce7c 100644 --- a/config/config.exs +++ b/config/config.exs @@ -13,13 +13,16 @@ config :real_world, RealWorldWeb.Endpoint, url: [host: "localhost"], secret_key_base: "9ueg5YcX8/LKzVUcDrXp5xpYuaBCUfZZAJ3/udC1LCoabotR3O1CJyf/u/6RLJ/N", render_errors: [view: RealWorldWeb.ErrorView, accepts: ~w(json)], - pubsub: [name: RealWorld.PubSub, adapter: Phoenix.PubSub.PG2] + pubsub_server: [name: RealWorld.PubSub, adapter: Phoenix.PubSub.PG2] # Configures Elixir's Logger config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] +# Use Jason for JSON parsing in Phoenix +config :phoenix, :json_library, Jason + config :real_world, RealWorldWeb.Guardian, issuer: "RealWorld", secret_key: "MDLMflIpKod5YCnkdiY7C4E3ki2rgcAAMwfBl0+vyC5uqJNgoibfQmAh7J3uZWVK", diff --git a/config/prod.exs b/config/prod.exs index cc3c66d..4dd62ce 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -2,15 +2,14 @@ use Mix.Config config :real_world, RealWorldWeb.Endpoint, load_from_system_env: true, - http: [port: {:system, "PORT"}], + http: [:inet6, port: System.get_env("PORT") || 4000], url: [scheme: "https", host: "https://real-world-example.herokuapp.com/", port: 443], force_ssl: [rewrite_on: [:x_forwarded_proto]], - secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE") + secret_key_base: System.get_env("SECRET_KEY_BASE") config :logger, level: :info config :real_world, RealWorld.Repo, - adapter: Ecto.Adapters.Postgres, url: System.get_env("DATABASE_URL"), pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), ssl: true diff --git a/config/test.exs b/config/test.exs index 0506a31..526bd02 100644 --- a/config/test.exs +++ b/config/test.exs @@ -3,7 +3,7 @@ use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. config :real_world, RealWorldWeb.Endpoint, - http: [port: 4001], + http: [port: 4002], server: false # Print only warnings and errors during test @@ -11,7 +11,6 @@ config :logger, level: :warn # Configure your database config :real_world, RealWorld.Repo, - adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "real_world_test", diff --git a/lib/real_world/accounts/encryption.ex b/lib/real_world/accounts/encryption.ex index 5a06132..3653743 100644 --- a/lib/real_world/accounts/encryption.ex +++ b/lib/real_world/accounts/encryption.ex @@ -1,6 +1,5 @@ defmodule RealWorld.Accounts.Encryption do - alias Comeonin.Bcrypt - def password_hashing(password), do: Bcrypt.hashpwsalt(password) - def validate_password(password, hash), do: Bcrypt.checkpw(password, hash) + def password_hashing(password), do: Bcrypt.hash_pwd_salt(password) + def validate_password(password, hash), do: Bcrypt.verify_pass(password, hash) end diff --git a/lib/real_world/application.ex b/lib/real_world/application.ex index 06d0ed7..44ac372 100644 --- a/lib/real_world/application.ex +++ b/lib/real_world/application.ex @@ -5,16 +5,17 @@ defmodule RealWorld.Application do # See http://elixir-lang.org/docs/stable/elixir/Application.html # for more information on OTP Applications def start(_type, _args) do - import Supervisor.Spec - - # Define workers and child supervisors to be supervised + # List all child processes to be supervised children = [ + + # Start the PubSub system + {Phoenix.PubSub, name: RealWorld.PubSub}, # Start the Ecto repository - supervisor(RealWorld.Repo, []), + RealWorld.Repo, # Start the endpoint when the application starts - supervisor(RealWorldWeb.Endpoint, []) - # Start your own worker by calling: RealWorld.Worker.start_link(arg1, arg2, arg3) - # worker(RealWorld.Worker, [arg1, arg2, arg3]), + RealWorldWeb.Endpoint + # Starts a worker by calling: RealWorld.Worker.start_link(arg) + # {RealWorld.Worker, arg}, ] # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html diff --git a/lib/real_world/repo.ex b/lib/real_world/repo.ex index 1a28af9..66ec82f 100644 --- a/lib/real_world/repo.ex +++ b/lib/real_world/repo.ex @@ -1,11 +1,5 @@ defmodule RealWorld.Repo do - use Ecto.Repo, otp_app: :real_world - - @doc """ - Dynamically loads the repository url from the - DATABASE_URL environment variable. - """ - def init(_, opts) do - {:ok, Keyword.put(opts, :url, System.get_env("DATABASE_URL"))} - end + use Ecto.Repo, + otp_app: :real_world, + adapter: Ecto.Adapters.Postgres end diff --git a/lib/real_world_web.ex b/lib/real_world_web.ex index 844003e..5eb9f13 100644 --- a/lib/real_world_web.ex +++ b/lib/real_world_web.ex @@ -21,8 +21,8 @@ defmodule RealWorldWeb do quote do use Phoenix.Controller, namespace: RealWorldWeb import Plug.Conn - import RealWorldWeb.Router.Helpers import RealWorldWeb.Gettext + alias RealWorldWeb.Router.Helpers, as: Routes end end @@ -35,9 +35,9 @@ defmodule RealWorldWeb do # Import convenience functions from controllers import Phoenix.Controller, only: [get_flash: 2, view_module: 1] - import RealWorldWeb.Router.Helpers import RealWorldWeb.ErrorHelpers import RealWorldWeb.Gettext + alias RealWorldWeb.Router.Helpers, as: Routes end end diff --git a/lib/real_world_web/channels/user_socket.ex b/lib/real_world_web/channels/user_socket.ex index afb5dda..619850d 100644 --- a/lib/real_world_web/channels/user_socket.ex +++ b/lib/real_world_web/channels/user_socket.ex @@ -4,10 +4,6 @@ defmodule RealWorldWeb.UserSocket do ## Channels # channel "room:*", RealWorldWeb.RoomChannel - ## Transports - transport(:websocket, Phoenix.Transports.WebSocket) - # transport :longpoll, Phoenix.Transports.LongPoll - # Socket params are passed from the client and can # be used to verify and authenticate a user. After # verification, you can put default assigns into @@ -19,7 +15,7 @@ defmodule RealWorldWeb.UserSocket do # # See `Phoenix.Token` documentation for examples in # performing token verification on connect. - def connect(_params, socket) do + def connect(_params, socket, _connect_info) do {:ok, socket} end diff --git a/lib/real_world_web/controllers/article_controller.ex b/lib/real_world_web/controllers/article_controller.ex index 153ca5e..a0a7a48 100644 --- a/lib/real_world_web/controllers/article_controller.ex +++ b/lib/real_world_web/controllers/article_controller.ex @@ -43,7 +43,7 @@ defmodule RealWorldWeb.ArticleController do conn |> put_status(:created) - |> put_resp_header("location", article_path(conn, :show, article)) + |> put_resp_header("location", Routes.article_path(conn, :show, article)) |> render("show.json", article: article) end end diff --git a/lib/real_world_web/controllers/fallback_controller.ex b/lib/real_world_web/controllers/fallback_controller.ex index 3045f27..19fb2b0 100644 --- a/lib/real_world_web/controllers/fallback_controller.ex +++ b/lib/real_world_web/controllers/fallback_controller.ex @@ -9,12 +9,14 @@ defmodule RealWorldWeb.FallbackController do def call(conn, {:error, %Ecto.Changeset{} = changeset}) do conn |> put_status(:unprocessable_entity) - |> render(RealWorldWeb.ChangesetView, "error.json", changeset: changeset) + |> put_view(RealWorldWeb.ChangesetView) + |> render("error.json", changeset: changeset) end def call(conn, {:error, :not_found}) do conn |> put_status(:not_found) - |> render(RealWorldWeb.ErrorView, :"404") + |> put_view(RealWorldWeb.ErrorView) + |> render(:"404") end end diff --git a/lib/real_world_web/controllers/session_controller.ex b/lib/real_world_web/controllers/session_controller.ex index e44cd8b..1ee84fa 100644 --- a/lib/real_world_web/controllers/session_controller.ex +++ b/lib/real_world_web/controllers/session_controller.ex @@ -13,18 +13,21 @@ defmodule RealWorldWeb.SessionController do conn |> put_status(:created) - |> render(RealWorldWeb.UserView, "login.json", jwt: jwt, user: user) + |> put_view(RealWorldWeb.UserView) + |> render("login.json", jwt: jwt, user: user) {:error, message} -> conn |> put_status(401) - |> render(RealWorldWeb.UserView, "error.json", message: message) + |> put_view(RealWorldWeb.UserView) + |> render("error.json", message: message) end end def auth_error(conn, {_type, _reason}, _opts) do conn |> put_status(:forbidden) - |> render(RealWorldWeb.UserView, "error.json", message: "Not Authenticated") + |> put_view(RealWorldWeb.UserView) + |> render("error.json", message: "Not Authenticated") end end diff --git a/lib/real_world_web/endpoint.ex b/lib/real_world_web/endpoint.ex index 2661643..20b3ef7 100644 --- a/lib/real_world_web/endpoint.ex +++ b/lib/real_world_web/endpoint.ex @@ -1,19 +1,17 @@ defmodule RealWorldWeb.Endpoint do use Phoenix.Endpoint, otp_app: :real_world - socket("/socket", RealWorldWeb.UserSocket) + socket "/socket", RealWorldWeb.UserSocket # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phoenix.digest # when deploying your static files in production. - plug( - Plug.Static, + plug Plug.Static, at: "/", from: :real_world, 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. @@ -21,28 +19,24 @@ defmodule RealWorldWeb.Endpoint do plug(Phoenix.CodeReloader) end - plug(Plug.RequestId) - plug(Plug.Logger) + plug Plug.RequestId + plug Plug.Logger - plug( - Plug.Parsers, + plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], - json_decoder: Poison - ) + json_decoder: Phoenix.json_library() - plug(Plug.MethodOverride) - plug(Plug.Head) + plug Plug.MethodOverride + plug Plug.Head # 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. - plug( - Plug.Session, + plug Plug.Session, store: :cookie, key: "_real_world_key", signing_salt: "Stn1Lrm3" - ) if Mix.env() == :dev do plug( @@ -52,17 +46,5 @@ defmodule RealWorldWeb.Endpoint do ) end - plug(RealWorldWeb.Router) - - @doc """ - Dynamically loads configuration from the system environment - on startup. - - It receives the endpoint configuration from the config files - and must return the updated configuration. - """ - def load_from_system_env(config) do - port = System.get_env("PORT") || raise "expected the PORT environment variable to be set" - {:ok, Keyword.put(config, :http, [:inet6, port: port])} - end + plug RealWorldWeb.Router end diff --git a/lib/real_world_web/views/error_view.ex b/lib/real_world_web/views/error_view.ex index 17fd06f..c76e4a2 100644 --- a/lib/real_world_web/views/error_view.ex +++ b/lib/real_world_web/views/error_view.ex @@ -9,9 +9,10 @@ defmodule RealWorldWeb.ErrorView do %{errors: %{detail: "Internal server error"}} end - # In case no render clause matches or no - # template is found, let's render it as 500 - def template_not_found(_template, assigns) do - render("500.json", assigns) + # By default, Phoenix returns the status message from + # the template name. For example, "404.html" becomes + # "Not Found". + def template_not_found(template, _assigns) do + Phoenix.Controller.status_message_from_template(template) end end diff --git a/mix.exs b/mix.exs index b71517f..3a3a205 100644 --- a/mix.exs +++ b/mix.exs @@ -1,4 +1,4 @@ -defmodule RealWorld.Mixfile do +defmodule RealWorld.MixProject do use Mix.Project def project do @@ -38,18 +38,19 @@ defmodule RealWorld.Mixfile do # Type `mix help deps` for examples and options. defp deps do [ - {:phoenix, "~> 1.3.0"}, - {:phoenix_pubsub, "~> 1.0"}, - {:phoenix_ecto, "~> 3.2"}, - {:postgrex, "~> 0.13.3"}, + {:phoenix, "~> 1.5.0"}, + {:phoenix_pubsub, "~> 1.1"}, + {:phoenix_ecto, "~> 4.0"}, + {:ecto_sql, "~> 3.0"}, + {:postgrex, ">= 0.0.0"}, {:gettext, "~> 0.11"}, - {:proper_case, "~> 1.0.0"}, - {:cowboy, "~> 1.1"}, - {:plug_cowboy, "~> 1.0.0"}, - {:comeonin, "~> 3.2"}, + {:proper_case, "~> 1.3"}, + {:plug_cowboy, "~> 2.2"}, + {:comeonin, "~> 5.0"}, + {:bcrypt_elixir, "~> 2.0"}, {:guardian, "~> 1.0"}, {:excoveralls, "~> 0.7", only: [:dev, :test]}, - {:credo, "~> 0.8.5", only: [:dev, :test]}, + {:credo, "~> 1.0", only: [:dev, :test]}, {:ex_machina, "~> 2.0", only: :test}, {:ex_doc, "~> 0.16", only: :dev, runtime: false}, {:plug, "~> 1.0"}, diff --git a/mix.lock b/mix.lock index bd2c962..a91d595 100644 --- a/mix.lock +++ b/mix.lock @@ -1,30 +1,29 @@ %{ "base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [:rebar], [], "hexpm"}, + "bcrypt_elixir": {:hex, :bcrypt_elixir, "2.0.2", "0ffbb490f34dee442d486b9f5f13e6a8f872f79d8ad92041c66a114ad0329df3", [:make, :mix], [{:comeonin, "~> 5.1", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"}, "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, - "comeonin": {:hex, :comeonin, "3.2.0", "cb10995a22aed6812667efb3856f548818c85d85394d8132bc116fbd6995c1ef", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"}, + "comeonin": {:hex, :comeonin, "5.1.1", "0abd6bae41acc01c369bb3eafe46399f301bf4e1bacebafdb89252bbb8a1a32d", [:mix], [], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, "corsica": {:hex, :corsica, "1.1.2", "5ad8b9dcbeeda4762d78a57c0c8c2f88e1eef8741508517c98cb79e0db1f107d", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, - "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"}, - "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, + "cowboy": {:hex, :cowboy, "2.6.3", "99aa50e94e685557cad82e704457336a453d4abcb77839ad22dbe71f311fcc06", [:rebar3], [{:cowlib, "~> 2.7.3", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, + "cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm"}, + "credo": {:hex, :credo, "1.0.4", "d2214d4cc88c07f54004ffd5a2a27408208841be5eca9f5a72ce9e8e835f7ede", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "db_connection": {:hex, :db_connection, "2.0.6", "bde2f85d047969c5b5800cb8f4b3ed6316c8cb11487afedac4aa5f93fd39abfa", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, "decimal": {:hex, :decimal, "1.7.0", "30d6b52c88541f9a66637359ddf85016df9eb266170d53105f02e4a67e00c5aa", [:mix], [], "hexpm"}, "earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "2.2.11", "4bb8f11718b72ba97a2696f65d247a379e739a0ecabf6a13ad1face79844791c", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, + "ecto": {:hex, :ecto, "3.1.1", "d6677f95f1e0bd39bc3db3db6b23a59977cb154ed2cceec69a56becd805128be", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, + "ecto_sql": {:hex, :ecto_sql, "3.1.0", "20d773799db0ed112dc4109305df679f1c8b0a59cf75e6d15ee05656af5bd708", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.1.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.1", [hex: :mariaex, repo: "hexpm", optional: true]}, {:myxql, "~> 0.2.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "elixir_make": {:hex, :elixir_make, "0.5.2", "96a28c79f5b8d34879cd95ebc04d2a0d678cfbbd3e74c43cb63a76adf0ee8054", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.20.1", "88eaa16e67c505664fd6a66f42ddb962d424ad68df586b214b71443c69887123", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "ex_machina": {:hex, :ex_machina, "2.3.0", "92a5ad0a8b10ea6314b876a99c8c9e3f25f4dde71a2a835845b136b9adaf199a", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm"}, "excoveralls": {:hex, :excoveralls, "0.10.6", "e2b9718c9d8e3ef90bc22278c3f76c850a9f9116faf4ebe9678063310742edc2", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, - "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm"}, "gettext": {:hex, :gettext, "0.16.1", "e2130b25eebcbe02bb343b119a07ae2c7e28bd4b146c4a154da2ffb2b3507af2", [:mix], [], "hexpm"}, "guardian": {:hex, :guardian, "1.2.1", "bdc8dd3dbf0fb7216cb6f91c11831faa1a64d39cdaed9a611e37f2413e584983", [:mix], [{:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.3", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm"}, "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, "jose": {:hex, :jose, "1.9.0", "4167c5f6d06ffaebffd15cdb8da61a108445ef5e85ab8f5a7ad926fdf3ada154", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"}, - "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"}, "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, @@ -32,20 +31,16 @@ "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.2", "1d71150d5293d703a9c38d4329da57d3935faed2031d64bc19e77b654ef2d177", [:mix], [], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, - "phoenix": {:hex, :phoenix, "1.3.4", "aaa1b55e5523083a877bcbe9886d9ee180bf2c8754905323493c2ac325903dc5", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "3.6.0", "d65dbcedd6af568d8582dcd7da516c3051016bad51f9953e5337fea40bcd8a9d", [:mix], [{:ecto, "~> 2.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_html": {:hex, :phoenix_html, "2.9.3", "1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.8", "4333f9c74190f485a74866beff2f9304f069d53f047f5fbb0fb8d1ee4c495f73", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix": {:hex, :phoenix, "1.4.3", "8eed4a64ff1e12372cd634724bddd69185938f52c18e1396ebac76375d85677d", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, + "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"}, "plug": {:hex, :plug, "1.8.0", "9d2685cb007fe5e28ed9ac27af2815bc262b7817a00929ac10f56f169f43b977", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, - "plug_cowboy": {:hex, :plug_cowboy, "1.0.0", "2e2a7d3409746d335f451218b8bb0858301c3de6d668c3052716c909936eb57a", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "plug_cowboy": {:hex, :plug_cowboy, "2.0.2", "6055f16868cc4882b24b6e1d63d2bada94fb4978413377a3b32ac16c18dffba2", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, - "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, - "poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm"}, - "postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"}, - "proper_case": {:hex, :proper_case, "1.0.2", "f80027bed740ae74cdce355c2ed7b4d1c6a5df923b2cfdef68ad3937067f0d87", [:mix], [], "hexpm"}, - "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"}, + "postgrex": {:hex, :postgrex, "0.14.2", "6680591bbce28d92f043249205e8b01b36cab9ef2a7911abc43649242e1a3b78", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, + "proper_case": {:hex, :proper_case, "1.3.0", "aea76589db691f4f9dd69b13ab951f268ba5dc9b4ffe7c8aff0dcce04d3be55c", [:mix], [], "hexpm"}, + "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, + "telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, - "uuid": {:hex, :uuid, "1.1.8", "e22fc04499de0de3ed1116b770c7737779f226ceefa0badb3592e64d5cfb4eb9", [:mix], [], "hexpm"}, } diff --git a/test/real_world_web/controllers/article_controller_test.exs b/test/real_world_web/controllers/article_controller_test.exs index 4f0363a..0d1b91a 100644 --- a/test/real_world_web/controllers/article_controller_test.exs +++ b/test/real_world_web/controllers/article_controller_test.exs @@ -19,13 +19,13 @@ defmodule RealWorldWeb.ArticleControllerTest do end test "lists all entries on index", %{conn: conn} do - conn = get(conn, article_path(conn, :index)) + conn = get(conn, Routes.article_path(conn, :index)) assert json_response(conn, 200)["articles"] != [] end test "creates article and renders article when data is valid", %{conn: conn, jwt: jwt} do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = post(conn, article_path(conn, :create), article: @create_attrs) + conn = post(conn, Routes.article_path(conn, :create), article: @create_attrs) json = json_response(conn, 201)["article"] assert json == %{ @@ -45,7 +45,7 @@ defmodule RealWorldWeb.ArticleControllerTest do test "does not create article and renders errors when data is invalid", %{conn: conn, jwt: jwt} do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = post(conn, article_path(conn, :create), article: @invalid_attrs) + conn = post(conn, Routes.article_path(conn, :create), article: @invalid_attrs) assert json_response(conn, 422)["errors"] != %{} end @@ -56,10 +56,10 @@ defmodule RealWorldWeb.ArticleControllerTest do } do article_id = article.id conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = put(conn, article_path(conn, :update, article), article: @update_attrs) + conn = put(conn, Routes.article_path(conn, :update, article), article: @update_attrs) assert %{"id" => ^article_id} = json_response(conn, 200)["article"] - conn = get(conn, article_path(conn, :show, "some-updated-title")) + conn = get(conn, Routes.article_path(conn, :show, "some-updated-title")) json = json_response(conn, 200)["article"] assert json == %{ @@ -80,7 +80,7 @@ defmodule RealWorldWeb.ArticleControllerTest do test "favorites the chosen article", %{conn: conn, jwt: jwt, article: article} do article_id = article.id conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = post(conn, article_path(conn, :favorite, article.slug)) + conn = post(conn, Routes.article_path(conn, :favorite, article.slug)) assert %{"id" => ^article_id, "favorited" => true} = json_response(conn, 200)["article"] end @@ -92,7 +92,7 @@ defmodule RealWorldWeb.ArticleControllerTest do } do insert(:favorite, user: user, article: article) conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = get(conn, article_path(conn, :show, article.slug)) + conn = get(conn, Routes.article_path(conn, :show, article.slug)) json = json_response(conn, 200)["article"] assert json == %{ @@ -123,7 +123,7 @@ defmodule RealWorldWeb.ArticleControllerTest do insert(:favorite, user: user, article: article) conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = delete(conn, article_path(conn, :unfavorite, article.slug)) + conn = delete(conn, Routes.article_path(conn, :unfavorite, article.slug)) json = json_response(conn, 200)["article"] assert json == %{ @@ -151,17 +151,17 @@ defmodule RealWorldWeb.ArticleControllerTest do article: article } do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = put(conn, article_path(conn, :update, article), article: @invalid_attrs) + conn = put(conn, Routes.article_path(conn, :update, article), article: @invalid_attrs) assert json_response(conn, 422)["errors"] != %{} end test "deletes chosen article", %{conn: conn, jwt: jwt, article: article} do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = delete(conn, article_path(conn, :delete, article)) + conn = delete(conn, Routes.article_path(conn, :delete, article)) assert response(conn, 204) assert_error_sent(404, fn -> - get(conn, article_path(conn, :show, article)) + get(conn, Routes.article_path(conn, :show, article)) end) end @@ -174,7 +174,7 @@ defmodule RealWorldWeb.ArticleControllerTest do insert(:favorite, user: user, article: article) conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = delete(conn, article_path(conn, :delete, article.slug)) + conn = delete(conn, Routes.article_path(conn, :delete, article.slug)) assert response(conn, 204) end end diff --git a/test/real_world_web/controllers/comment_controller_test.exs b/test/real_world_web/controllers/comment_controller_test.exs index c33b1fd..1a2f45c 100644 --- a/test/real_world_web/controllers/comment_controller_test.exs +++ b/test/real_world_web/controllers/comment_controller_test.exs @@ -25,7 +25,7 @@ defmodule RealWorldWeb.CommentControllerTest do describe "index" do test "lists all comments", %{conn: conn, jwt: jwt, article: article} do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = get(conn, comment_path(conn, :index), article_id: article.slug) + conn = get(conn, Routes.comment_path(conn, :index), article_id: article.slug) assert json_response(conn, 200)["comments"] != [] end end @@ -37,7 +37,7 @@ defmodule RealWorldWeb.CommentControllerTest do article: article } do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = post(conn, article_comment_path(conn, :create, article.slug), comment: @create_attrs) + conn = post(conn, Routes.article_comment_path(conn, :create, article.slug), comment: @create_attrs) json_response(conn, 201)["comment"] end end @@ -51,13 +51,13 @@ defmodule RealWorldWeb.CommentControllerTest do comment: %Comment{id: id} = comment } do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = put(conn, comment_path(conn, :update, comment), comment: @update_attrs) + conn = put(conn, Routes.comment_path(conn, :update, comment), comment: @update_attrs) assert %{"id" => ^id, "body" => "some updated body"} = json_response(conn, 200)["comment"] end test "renders errors when data is invalid", %{conn: conn, jwt: jwt, comment: comment} do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = put(conn, comment_path(conn, :update, comment), comment: @invalid_attrs) + conn = put(conn, Routes.comment_path(conn, :update, comment), comment: @invalid_attrs) assert json_response(conn, 422)["errors"] != %{} end end @@ -67,7 +67,7 @@ defmodule RealWorldWeb.CommentControllerTest do test "deletes chosen comment", %{conn: conn, jwt: jwt, comment: comment} do conn = conn |> put_req_header("authorization", "Token #{jwt}") - conn = delete(conn, comment_path(conn, :delete, comment)) + conn = delete(conn, Routes.comment_path(conn, :delete, comment)) assert response(conn, 204) end end diff --git a/test/real_world_web/controllers/profile_controller_test.exs b/test/real_world_web/controllers/profile_controller_test.exs index d6514fb..5aa9b40 100644 --- a/test/real_world_web/controllers/profile_controller_test.exs +++ b/test/real_world_web/controllers/profile_controller_test.exs @@ -42,7 +42,7 @@ defmodule RealWorldWeb.ProfileControllerTest do test "return valid profile and following:nil if disconnected", %{conn: conn} do user1 = fixture(:user1) - conn = get(conn, profile_path(conn, :show, user1.username)) + conn = get(conn, Routes.profile_path(conn, :show, user1.username)) json = json_response(conn, 200)["profile"] assert json == %{ @@ -55,7 +55,7 @@ defmodule RealWorldWeb.ProfileControllerTest do test "return valid profile and following:false if connected", %{conn: conn} do user2 = fixture(:user2) - conn = get(secure_conn(conn), profile_path(conn, :show, user2.username)) + conn = get(secure_conn(conn), Routes.profile_path(conn, :show, user2.username)) json = json_response(conn, 200)["profile"] assert json == %{ @@ -68,7 +68,7 @@ defmodule RealWorldWeb.ProfileControllerTest do test "follow endpoint is only reachable if connected", %{conn: conn} do user2 = fixture(:user2) - conn = post(conn, profile_path(conn, :follow, user2.username)) + conn = post(conn, Routes.profile_path(conn, :follow, user2.username)) json = json_response(conn, 403) assert json == %{ @@ -78,7 +78,7 @@ defmodule RealWorldWeb.ProfileControllerTest do test "unfollow endpoint is only reachable if connected", %{conn: conn} do user2 = fixture(:user2) - conn = post(conn, profile_path(conn, :follow, user2.username)) + conn = post(conn, Routes.profile_path(conn, :follow, user2.username)) json = json_response(conn, 403) assert json == %{ @@ -88,7 +88,7 @@ defmodule RealWorldWeb.ProfileControllerTest do test "set following to true if follow user", %{conn: conn} do user2 = fixture(:user2) - conn = post(secure_conn(conn), profile_path(conn, :follow, user2.username)) + conn = post(secure_conn(conn), Routes.profile_path(conn, :follow, user2.username)) json = json_response(conn, 200)["profile"] assert json == %{ @@ -103,7 +103,7 @@ defmodule RealWorldWeb.ProfileControllerTest do new_conn = secure_conn(conn) user2 = fixture(:user2) - conn = post(new_conn, profile_path(conn, :follow, user2.username)) + conn = post(new_conn, Routes.profile_path(conn, :follow, user2.username)) json = json_response(conn, 200)["profile"] assert json == %{ @@ -113,7 +113,7 @@ defmodule RealWorldWeb.ProfileControllerTest do "following" => true } - conn = delete(new_conn, profile_path(conn, :unfollow, user2.username)) + conn = delete(new_conn, Routes.profile_path(conn, :unfollow, user2.username)) json = json_response(conn, 200)["profile"] assert json == %{ diff --git a/test/real_world_web/controllers/session_controller_test.exs b/test/real_world_web/controllers/session_controller_test.exs index 02dc961..36403b2 100644 --- a/test/real_world_web/controllers/session_controller_test.exs +++ b/test/real_world_web/controllers/session_controller_test.exs @@ -30,7 +30,7 @@ defmodule RealWorldWeb.SessionControllerTest do end test "creates user and renders user when data is valid", %{conn: conn} do - conn = post(secure_conn(conn), session_path(conn, :create), user: @user_login_attrs) + conn = post(secure_conn(conn), Routes.session_path(conn, :create), user: @user_login_attrs) json = json_response(conn, 201)["user"] assert json == %{ diff --git a/test/real_world_web/controllers/tag_controller_test.exs b/test/real_world_web/controllers/tag_controller_test.exs index ae2d56d..8e70d8c 100644 --- a/test/real_world_web/controllers/tag_controller_test.exs +++ b/test/real_world_web/controllers/tag_controller_test.exs @@ -9,7 +9,7 @@ defmodule RealWorldWeb.TagControllerTest do end test "lists all entries on index", %{conn: conn} do - conn = get(conn, tag_path(conn, :index)) + conn = get(conn, Routes.tag_path(conn, :index)) assert json_response(conn, 200)["tags"] == ["tag1", "tag2"] end end diff --git a/test/real_world_web/controllers/user_controller_test.exs b/test/real_world_web/controllers/user_controller_test.exs index 9c3afb0..e9d9ce7 100644 --- a/test/real_world_web/controllers/user_controller_test.exs +++ b/test/real_world_web/controllers/user_controller_test.exs @@ -37,7 +37,7 @@ defmodule RealWorldWeb.UserControllerTest do end test "creates user and renders user when data is valid", %{conn: conn} do - conn = post(conn, user_path(conn, :create), user: @user_create_attrs) + conn = post(conn, Routes.user_path(conn, :create), user: @user_create_attrs) json = json_response(conn, 201)["user"] assert json == %{ @@ -53,7 +53,7 @@ defmodule RealWorldWeb.UserControllerTest do end test "view current_user data", %{conn: conn} do - conn = get(secure_conn(conn), user_path(conn, :current_user)) + conn = get(secure_conn(conn), Routes.user_path(conn, :current_user)) json = json_response(conn, 200)["user"] assert json == %{ @@ -69,7 +69,7 @@ defmodule RealWorldWeb.UserControllerTest do end test "update current_user data", %{conn: conn} do - conn = put(secure_conn(conn), user_path(conn, :update), user: @user_update_attrs) + conn = put(secure_conn(conn), Routes.user_path(conn, :update), user: @user_update_attrs) json = json_response(conn, 200)["user"] assert json == %{ diff --git a/test/real_world_web/views/error_view_test.exs b/test/real_world_web/views/error_view_test.exs index ba2ca8d..2ec19ba 100644 --- a/test/real_world_web/views/error_view_test.exs +++ b/test/real_world_web/views/error_view_test.exs @@ -13,9 +13,4 @@ defmodule RealWorldWeb.ErrorViewTest do assert render(RealWorldWeb.ErrorView, "500.json", []) == %{errors: %{detail: "Internal server error"}} end - - test "render any other" do - assert render(RealWorldWeb.ErrorView, "505.json", []) == - %{errors: %{detail: "Internal server error"}} - end end diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index db5b4d2..a67a320 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -18,8 +18,9 @@ defmodule RealWorldWeb.ConnCase do using do quote do # Import conveniences for testing with connections - use Phoenix.ConnTest - import RealWorldWeb.Router.Helpers + import Plug.Conn + import Phoenix.ConnTest + alias RealWorldWeb.Router.Helpers, as: Routes # The default endpoint for testing @endpoint RealWorldWeb.Endpoint