Compare commits

...

2 Commits

Author SHA1 Message Date
994aa96a20 simply assigns
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-14 20:32:47 -04:00
026bf22f60 improve formatting 2023-04-14 20:08:03 -04:00
6 changed files with 13 additions and 53 deletions

View File

@ -88,9 +88,7 @@ defmodule MemexWeb.Components.NotesTableComponent do
@spec get_value_for_key(atom(), Note.t(), additional_data :: map()) ::
any() | {any(), Rendered.t()}
defp get_value_for_key(:slug, %{slug: slug}, _additional_data) do
assigns = %{slug: slug}
defp get_value_for_key(:slug, %{slug: slug} = assigns, _additional_data) do
slug_block = ~H"""
<.link navigate={~p"/note/#{@slug}"} class="link">
<%= @slug %>
@ -100,9 +98,7 @@ defmodule MemexWeb.Components.NotesTableComponent do
{slug, slug_block}
end
defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do
assigns = %{tags: tags}
defp get_value_for_key(:tags, assigns, _additional_data) do
~H"""
<div class="flex flex-wrap justify-center space-x-1">
<.link :for={tag <- @tags} patch={~p"/notes/#{tag}"} class="link">

View File

@ -89,9 +89,7 @@ defmodule MemexWeb.Components.PipelinesTableComponent do
@spec get_value_for_key(atom(), Pipeline.t(), additional_data :: map()) ::
any() | {any(), Rendered.t()}
defp get_value_for_key(:slug, %{slug: slug}, _additional_data) do
assigns = %{slug: slug}
defp get_value_for_key(:slug, %{slug: slug} = assigns, _additional_data) do
slug_block = ~H"""
<.link navigate={~p"/pipeline/#{@slug}"} class="link">
<%= @slug %>
@ -101,9 +99,7 @@ defmodule MemexWeb.Components.PipelinesTableComponent do
{slug, slug_block}
end
defp get_value_for_key(:description, %{description: description}, _additional_data) do
assigns = %{description: description}
defp get_value_for_key(:description, %{description: description} = assigns, _additional_data) do
description_block = ~H"""
<div class="truncate max-w-sm">
<%= @description %>
@ -113,9 +109,7 @@ defmodule MemexWeb.Components.PipelinesTableComponent do
{description, description_block}
end
defp get_value_for_key(:tags, %{tags: tags}, _additional_data) do
assigns = %{tags: tags}
defp get_value_for_key(:tags, assigns, _additional_data) do
~H"""
<div class="flex flex-wrap justify-center space-x-1">
<.link :for={tag <- @tags} patch={~p"/pipelines/#{tag}"} class="link">

View File

@ -23,11 +23,7 @@ defmodule MemexWeb.UserConfirmationControllerTest do
describe "POST /users/confirm" do
@tag :capture_log
test "sends a new confirmation token", %{conn: conn, user: user} do
conn =
post(conn, ~p"/users/confirm", %{
user: %{email: user.email}
})
conn = post(conn, ~p"/users/confirm", %{user: %{email: user.email}})
assert redirected_to(conn) == ~p"/"
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
Repo.update!(Accounts.User.confirm_changeset(user))
conn =
post(conn, ~p"/users/confirm", %{
user: %{email: user.email}
})
conn = post(conn, ~p"/users/confirm", %{user: %{email: user.email}})
assert redirected_to(conn) == ~p"/"
conn.assigns.flash["info"] =~
@ -51,11 +43,7 @@ defmodule MemexWeb.UserConfirmationControllerTest do
end
test "does not send confirmation token if email is invalid", %{conn: conn} do
conn =
post(conn, ~p"/users/confirm", %{
user: %{email: "unknown@example.com"}
})
conn = post(conn, ~p"/users/confirm", %{user: %{email: "unknown@example.com"}})
assert redirected_to(conn) == ~p"/"
conn.assigns.flash["info"] =~

View File

@ -25,11 +25,7 @@ defmodule MemexWeb.UserRegistrationControllerTest do
@tag :capture_log
test "creates account and logs the user in", %{conn: conn} do
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) == %{
"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
conn =
post(conn, ~p"/users/register", %{
user: %{email: "with spaces", password: "too short"}
})
post(conn, ~p"/users/register", %{user: %{email: "with spaces", password: "too short"}})
response = html_response(conn, 200)
assert response =~ "register"

View File

@ -23,11 +23,7 @@ defmodule MemexWeb.UserResetPasswordControllerTest do
describe "POST /users/reset_password" do
@tag :capture_log
test "sends a new reset password token", %{conn: conn, user: user} do
conn =
post(conn, ~p"/users/reset_password", %{
user: %{email: user.email}
})
conn = post(conn, ~p"/users/reset_password", %{user: %{email: user.email}})
assert redirected_to(conn) == ~p"/"
conn.assigns.flash["info"] =~
@ -37,11 +33,7 @@ defmodule MemexWeb.UserResetPasswordControllerTest do
end
test "does not send reset password token if email is invalid", %{conn: conn} do
conn =
post(conn, ~p"/users/reset_password", %{
user: %{email: "unknown@example.com"}
})
conn = post(conn, ~p"/users/reset_password", %{user: %{email: "unknown@example.com"}})
assert redirected_to(conn) == ~p"/"
conn.assigns.flash["info"] =~

View File

@ -71,11 +71,7 @@ defmodule MemexWeb.UserSessionControllerTest do
test "emits error message with invalid credentials",
%{conn: conn, current_user: current_user} do
conn =
post(conn, ~p"/users/log_in", %{
user: %{email: current_user.email, password: "bad"}
})
conn = post(conn, ~p"/users/log_in", %{user: %{email: current_user.email, password: "bad"}})
response = html_response(conn, 200)
assert response =~ "log in"
assert response =~ "invalid email or password"