Compare commits
2 Commits
56e6eb3609
...
994aa96a20
Author | SHA1 | Date | |
---|---|---|---|
994aa96a20 | |||
026bf22f60 |
@ -88,9 +88,7 @@ defmodule MemexWeb.Components.NotesTableComponent do
|
|||||||
|
|
||||||
@spec get_value_for_key(atom(), Note.t(), additional_data :: map()) ::
|
@spec get_value_for_key(atom(), Note.t(), additional_data :: map()) ::
|
||||||
any() | {any(), Rendered.t()}
|
any() | {any(), Rendered.t()}
|
||||||
defp get_value_for_key(:slug, %{slug: slug}, _additional_data) do
|
defp get_value_for_key(:slug, %{slug: slug} = assigns, _additional_data) do
|
||||||
assigns = %{slug: slug}
|
|
||||||
|
|
||||||
slug_block = ~H"""
|
slug_block = ~H"""
|
||||||
<.link navigate={~p"/note/#{@slug}"} class="link">
|
<.link navigate={~p"/note/#{@slug}"} class="link">
|
||||||
<%= @slug %>
|
<%= @slug %>
|
||||||
@ -100,9 +98,7 @@ defmodule MemexWeb.Components.NotesTableComponent do
|
|||||||
{slug, slug_block}
|
{slug, slug_block}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do
|
defp get_value_for_key(:tags, assigns, _additional_data) do
|
||||||
assigns = %{tags: tags}
|
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div class="flex flex-wrap justify-center space-x-1">
|
<div class="flex flex-wrap justify-center space-x-1">
|
||||||
<.link :for={tag <- @tags} patch={~p"/notes/#{tag}"} class="link">
|
<.link :for={tag <- @tags} patch={~p"/notes/#{tag}"} class="link">
|
||||||
|
@ -89,9 +89,7 @@ defmodule MemexWeb.Components.PipelinesTableComponent do
|
|||||||
|
|
||||||
@spec get_value_for_key(atom(), Pipeline.t(), additional_data :: map()) ::
|
@spec get_value_for_key(atom(), Pipeline.t(), additional_data :: map()) ::
|
||||||
any() | {any(), Rendered.t()}
|
any() | {any(), Rendered.t()}
|
||||||
defp get_value_for_key(:slug, %{slug: slug}, _additional_data) do
|
defp get_value_for_key(:slug, %{slug: slug} = assigns, _additional_data) do
|
||||||
assigns = %{slug: slug}
|
|
||||||
|
|
||||||
slug_block = ~H"""
|
slug_block = ~H"""
|
||||||
<.link navigate={~p"/pipeline/#{@slug}"} class="link">
|
<.link navigate={~p"/pipeline/#{@slug}"} class="link">
|
||||||
<%= @slug %>
|
<%= @slug %>
|
||||||
@ -101,9 +99,7 @@ defmodule MemexWeb.Components.PipelinesTableComponent do
|
|||||||
{slug, slug_block}
|
{slug, slug_block}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_value_for_key(:description, %{description: description}, _additional_data) do
|
defp get_value_for_key(:description, %{description: description} = assigns, _additional_data) do
|
||||||
assigns = %{description: description}
|
|
||||||
|
|
||||||
description_block = ~H"""
|
description_block = ~H"""
|
||||||
<div class="truncate max-w-sm">
|
<div class="truncate max-w-sm">
|
||||||
<%= @description %>
|
<%= @description %>
|
||||||
@ -113,9 +109,7 @@ defmodule MemexWeb.Components.PipelinesTableComponent do
|
|||||||
{description, description_block}
|
{description, description_block}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do
|
defp get_value_for_key(:tags, assigns, _additional_data) do
|
||||||
assigns = %{tags: tags}
|
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div class="flex flex-wrap justify-center space-x-1">
|
<div class="flex flex-wrap justify-center space-x-1">
|
||||||
<.link :for={tag <- @tags} patch={~p"/pipelines/#{tag}"} class="link">
|
<.link :for={tag <- @tags} patch={~p"/pipelines/#{tag}"} class="link">
|
||||||
|
@ -23,11 +23,7 @@ defmodule MemexWeb.UserConfirmationControllerTest do
|
|||||||
describe "POST /users/confirm" do
|
describe "POST /users/confirm" do
|
||||||
@tag :capture_log
|
@tag :capture_log
|
||||||
test "sends a new confirmation token", %{conn: conn, user: user} do
|
test "sends a new confirmation token", %{conn: conn, user: user} do
|
||||||
conn =
|
conn = post(conn, ~p"/users/confirm", %{user: %{email: user.email}})
|
||||||
post(conn, ~p"/users/confirm", %{
|
|
||||||
user: %{email: user.email}
|
|
||||||
})
|
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/"
|
assert redirected_to(conn) == ~p"/"
|
||||||
|
|
||||||
conn.assigns.flash["info"] =~
|
conn.assigns.flash["info"] =~
|
||||||
@ -39,11 +35,7 @@ defmodule MemexWeb.UserConfirmationControllerTest do
|
|||||||
test "does not send confirmation token if User is confirmed", %{conn: conn, user: user} do
|
test "does not send confirmation token if User is confirmed", %{conn: conn, user: user} do
|
||||||
Repo.update!(Accounts.User.confirm_changeset(user))
|
Repo.update!(Accounts.User.confirm_changeset(user))
|
||||||
|
|
||||||
conn =
|
conn = post(conn, ~p"/users/confirm", %{user: %{email: user.email}})
|
||||||
post(conn, ~p"/users/confirm", %{
|
|
||||||
user: %{email: user.email}
|
|
||||||
})
|
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/"
|
assert redirected_to(conn) == ~p"/"
|
||||||
|
|
||||||
conn.assigns.flash["info"] =~
|
conn.assigns.flash["info"] =~
|
||||||
@ -51,11 +43,7 @@ defmodule MemexWeb.UserConfirmationControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "does not send confirmation token if email is invalid", %{conn: conn} do
|
test "does not send confirmation token if email is invalid", %{conn: conn} do
|
||||||
conn =
|
conn = post(conn, ~p"/users/confirm", %{user: %{email: "unknown@example.com"}})
|
||||||
post(conn, ~p"/users/confirm", %{
|
|
||||||
user: %{email: "unknown@example.com"}
|
|
||||||
})
|
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/"
|
assert redirected_to(conn) == ~p"/"
|
||||||
|
|
||||||
conn.assigns.flash["info"] =~
|
conn.assigns.flash["info"] =~
|
||||||
|
@ -25,11 +25,7 @@ defmodule MemexWeb.UserRegistrationControllerTest do
|
|||||||
@tag :capture_log
|
@tag :capture_log
|
||||||
test "creates account and logs the user in", %{conn: conn} do
|
test "creates account and logs the user in", %{conn: conn} do
|
||||||
email = unique_user_email()
|
email = unique_user_email()
|
||||||
|
conn = post(conn, ~p"/users/register", %{user: valid_user_attributes(email: email)})
|
||||||
conn =
|
|
||||||
post(conn, ~p"/users/register", %{
|
|
||||||
user: valid_user_attributes(email: email)
|
|
||||||
})
|
|
||||||
|
|
||||||
assert get_session(conn, :phoenix_flash) == %{
|
assert get_session(conn, :phoenix_flash) == %{
|
||||||
"info" => "please check your email to verify your account"
|
"info" => "please check your email to verify your account"
|
||||||
@ -40,9 +36,7 @@ defmodule MemexWeb.UserRegistrationControllerTest do
|
|||||||
|
|
||||||
test "render errors for invalid data", %{conn: conn} do
|
test "render errors for invalid data", %{conn: conn} do
|
||||||
conn =
|
conn =
|
||||||
post(conn, ~p"/users/register", %{
|
post(conn, ~p"/users/register", %{user: %{email: "with spaces", password: "too short"}})
|
||||||
user: %{email: "with spaces", password: "too short"}
|
|
||||||
})
|
|
||||||
|
|
||||||
response = html_response(conn, 200)
|
response = html_response(conn, 200)
|
||||||
assert response =~ "register"
|
assert response =~ "register"
|
||||||
|
@ -23,11 +23,7 @@ defmodule MemexWeb.UserResetPasswordControllerTest do
|
|||||||
describe "POST /users/reset_password" do
|
describe "POST /users/reset_password" do
|
||||||
@tag :capture_log
|
@tag :capture_log
|
||||||
test "sends a new reset password token", %{conn: conn, user: user} do
|
test "sends a new reset password token", %{conn: conn, user: user} do
|
||||||
conn =
|
conn = post(conn, ~p"/users/reset_password", %{user: %{email: user.email}})
|
||||||
post(conn, ~p"/users/reset_password", %{
|
|
||||||
user: %{email: user.email}
|
|
||||||
})
|
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/"
|
assert redirected_to(conn) == ~p"/"
|
||||||
|
|
||||||
conn.assigns.flash["info"] =~
|
conn.assigns.flash["info"] =~
|
||||||
@ -37,11 +33,7 @@ defmodule MemexWeb.UserResetPasswordControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "does not send reset password token if email is invalid", %{conn: conn} do
|
test "does not send reset password token if email is invalid", %{conn: conn} do
|
||||||
conn =
|
conn = post(conn, ~p"/users/reset_password", %{user: %{email: "unknown@example.com"}})
|
||||||
post(conn, ~p"/users/reset_password", %{
|
|
||||||
user: %{email: "unknown@example.com"}
|
|
||||||
})
|
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/"
|
assert redirected_to(conn) == ~p"/"
|
||||||
|
|
||||||
conn.assigns.flash["info"] =~
|
conn.assigns.flash["info"] =~
|
||||||
|
@ -71,11 +71,7 @@ defmodule MemexWeb.UserSessionControllerTest do
|
|||||||
|
|
||||||
test "emits error message with invalid credentials",
|
test "emits error message with invalid credentials",
|
||||||
%{conn: conn, current_user: current_user} do
|
%{conn: conn, current_user: current_user} do
|
||||||
conn =
|
conn = post(conn, ~p"/users/log_in", %{user: %{email: current_user.email, password: "bad"}})
|
||||||
post(conn, ~p"/users/log_in", %{
|
|
||||||
user: %{email: current_user.email, password: "bad"}
|
|
||||||
})
|
|
||||||
|
|
||||||
response = html_response(conn, 200)
|
response = html_response(conn, 200)
|
||||||
assert response =~ "log in"
|
assert response =~ "log in"
|
||||||
assert response =~ "invalid email or password"
|
assert response =~ "invalid email or password"
|
||||||
|
Loading…
Reference in New Issue
Block a user