From 31d0e01e95cf00fdcf244e46f6fcbe46a3991497 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sat, 31 Aug 2024 15:22:07 +0300 Subject: [PATCH] Update the routes for Accounts to use hyphens. --- lib/link_shortener_web/router.ex | 6 +++--- .../api/v1/accounts_controller_test.exs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/link_shortener_web/router.ex b/lib/link_shortener_web/router.ex index 727558f..d845cde 100644 --- a/lib/link_shortener_web/router.ex +++ b/lib/link_shortener_web/router.ex @@ -32,8 +32,8 @@ defmodule LinkShortenerWeb.Router do pipe_through :api scope "/v1", Api.V1, as: :v1 do - post "/users/sign_up", AccountsController, :sign_up - post "/users/sign_in", AccountsController, :sign_in + post "/users/sign-up", AccountsController, :sign_up + post "/users/sign-in", AccountsController, :sign_in end end @@ -41,7 +41,7 @@ defmodule LinkShortenerWeb.Router do pipe_through [:api, :auth] scope "/v1", Api.V1, as: :v1 do - post "/users/sign_out", AccountsController, :sign_out + post "/users/sign-out", AccountsController, :sign_out resources "/links", LinkController end diff --git a/test/link_shortener_web/controllers/api/v1/accounts_controller_test.exs b/test/link_shortener_web/controllers/api/v1/accounts_controller_test.exs index 846bf52..69d401c 100644 --- a/test/link_shortener_web/controllers/api/v1/accounts_controller_test.exs +++ b/test/link_shortener_web/controllers/api/v1/accounts_controller_test.exs @@ -31,7 +31,7 @@ defmodule LinkShortenerWeb.Api.V1.AccountsControllerTest do describe "create user with sign up" do test "renders user when data is valid", %{conn: conn} do - conn = post(conn, ~p"/api/v1/users/sign_up", user: @create_attrs) + conn = post(conn, ~p"/api/v1/users/sign-up", user: @create_attrs) assert %{ "email" => "user@mail.com", "token" => token @@ -39,7 +39,7 @@ defmodule LinkShortenerWeb.Api.V1.AccountsControllerTest do end test "renders errors when data is invalid", %{conn: conn} do - conn = post(conn, ~p"/api/v1/users/sign_up", user: @invalid_attrs) + conn = post(conn, ~p"/api/v1/users/sign-up", user: @invalid_attrs) assert json_response(conn, 422)["errors"] != %{} end end @@ -48,7 +48,7 @@ defmodule LinkShortenerWeb.Api.V1.AccountsControllerTest do setup [:create_user] test "renders user when data is valid", %{conn: conn} do - conn = post(conn, ~p"/api/v1/users/sign_in", @create_attrs) + conn = post(conn, ~p"/api/v1/users/sign-in", @create_attrs) assert %{ "email" => email, @@ -57,7 +57,7 @@ defmodule LinkShortenerWeb.Api.V1.AccountsControllerTest do end test "renders errors when data is invalid", %{conn: conn} do - conn = post(conn, ~p"/api/v1/users/sign_in", @invalid_password_attrs) + conn = post(conn, ~p"/api/v1/users/sign-in", @invalid_password_attrs) assert %{ "errors" => %{"detail" => "Unauthorized"} } = json_response(conn, 401) @@ -78,7 +78,7 @@ defmodule LinkShortenerWeb.Api.V1.AccountsControllerTest do end test "renders the message and the token if successfully sign out", %{conn: conn, token: token} do - conn = post(conn, ~p"/api/v1/users/sign_out", %{}) + conn = post(conn, ~p"/api/v1/users/sign-out", %{}) assert %{ "message" => "Successfully sign out", @@ -88,9 +88,9 @@ defmodule LinkShortenerWeb.Api.V1.AccountsControllerTest do test "renders errors if the token is invalid after revoke", %{conn: conn, token: token} do # revoking - conn = post(conn, ~p"/api/v1/users/sign_out", %{}) + conn = post(conn, ~p"/api/v1/users/sign-out", %{}) # second revoking - conn = post(conn, ~p"/api/v1/users/sign_out", %{}) + conn = post(conn, ~p"/api/v1/users/sign-out", %{}) assert %{ "error" => "invalid_token"