Add the auth pipeline for the Link API path.
This commit is contained in:
@@ -2,6 +2,7 @@ defmodule LinkShortenerWeb.Api.V1.LinkControllerTest do
|
||||
use LinkShortenerWeb.ConnCase
|
||||
|
||||
import LinkShortener.LinksFixtures
|
||||
import LinkShortener.AccountsFixtures
|
||||
|
||||
alias LinkShortener.Links.Link
|
||||
alias LinkShortener.Links
|
||||
@@ -23,7 +24,13 @@ defmodule LinkShortenerWeb.Api.V1.LinkControllerTest do
|
||||
}
|
||||
|
||||
setup %{conn: conn} do
|
||||
{:ok, conn: put_req_header(conn, "accept", "application/json")}
|
||||
%{token: token} = create_user_token()
|
||||
|
||||
conn = conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("authorization", "Bearer #{token}")
|
||||
|
||||
{:ok, conn: conn}
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
@@ -90,6 +97,11 @@ defmodule LinkShortenerWeb.Api.V1.LinkControllerTest do
|
||||
end
|
||||
end
|
||||
|
||||
defp create_user_token() do
|
||||
token = user_token_fixture()
|
||||
%{token: token}
|
||||
end
|
||||
|
||||
defp create_link(_) do
|
||||
link = link_fixture()
|
||||
%{link: link}
|
||||
|
||||
Reference in New Issue
Block a user