improve invites, record usage

This commit is contained in:
2023-02-04 17:22:06 -05:00
parent eb75937587
commit cd7220cea3
37 changed files with 902 additions and 614 deletions

View File

@ -23,8 +23,8 @@ defmodule MemexWeb.ContextLiveTest do
"visibility" => nil
}
defp create_context(%{user: user}) do
[context: context_fixture(user)]
defp create_context(%{current_user: current_user}) do
[context: context_fixture(current_user)]
end
describe "Index" do
@ -148,13 +148,16 @@ defmodule MemexWeb.ContextLiveTest do
describe "show with note" do
setup [:register_and_log_in_user]
setup %{user: user} do
%{slug: note_slug} = note = note_fixture(user)
setup %{current_user: current_user} do
%{slug: note_slug} = note = note_fixture(current_user)
[
note: note,
context:
context_fixture(%{content: "example with backlink to [[#{note_slug}]] note"}, user)
context_fixture(
%{content: "example with backlink to [[#{note_slug}]] note"},
current_user
)
]
end

View File

@ -6,7 +6,7 @@ defmodule MemexWeb.InviteLiveTest do
use MemexWeb.ConnCase
import Phoenix.LiveViewTest
import MemexWeb.Gettext
alias Memex.Invites
alias Memex.Accounts.Invites
@moduletag :invite_live_test
@create_attrs %{"name" => "some name"}
@ -16,9 +16,9 @@ defmodule MemexWeb.InviteLiveTest do
describe "Index" do
setup [:register_and_log_in_user]
setup %{user: user} do
{:ok, invite} = Invites.create_invite(user, @create_attrs)
%{invite: invite, user: user}
setup %{current_user: current_user} do
{:ok, invite} = Invites.create_invite(current_user, @create_attrs)
%{invite: invite, current_user: current_user}
end
test "lists all invites", %{conn: conn, invite: invite} do

View File

@ -24,8 +24,8 @@ defmodule MemexWeb.NoteLiveTest do
"visibility" => nil
}
defp create_note(%{user: user}) do
[note: note_fixture(user)]
defp create_note(%{current_user: current_user}) do
[note: note_fixture(current_user)]
end
describe "Index" do
@ -149,13 +149,13 @@ defmodule MemexWeb.NoteLiveTest do
describe "show with note" do
setup [:register_and_log_in_user]
setup %{user: user} do
%{slug: note_slug} = note = note_fixture(user)
setup %{current_user: current_user} do
%{slug: note_slug} = note = note_fixture(current_user)
[
note: note,
backlinked_note:
note_fixture(%{content: "example with backlink to [[#{note_slug}]] note"}, user)
note_fixture(%{content: "example with backlink to [[#{note_slug}]] note"}, current_user)
]
end

View File

@ -34,8 +34,8 @@ defmodule MemexWeb.PipelineLiveTest do
"title" => nil
}
defp create_pipeline(%{user: user}) do
[pipeline: pipeline_fixture(user)]
defp create_pipeline(%{current_user: current_user}) do
[pipeline: pipeline_fixture(current_user)]
end
describe "Index" do
@ -181,9 +181,9 @@ defmodule MemexWeb.PipelineLiveTest do
describe "show with a step" do
setup [:register_and_log_in_user, :create_pipeline]
setup %{pipeline: pipeline, user: user} do
setup %{pipeline: pipeline, current_user: current_user} do
[
step: step_fixture(0, pipeline, user)
step: step_fixture(0, pipeline, current_user)
]
end
@ -236,11 +236,11 @@ defmodule MemexWeb.PipelineLiveTest do
describe "show with multiple steps" do
setup [:register_and_log_in_user, :create_pipeline]
setup %{pipeline: pipeline, user: user} do
setup %{pipeline: pipeline, current_user: current_user} do
[
first_step: step_fixture(%{title: "first step"}, 0, pipeline, user),
second_step: step_fixture(%{title: "second step"}, 1, pipeline, user),
third_step: step_fixture(%{title: "third step"}, 2, pipeline, user)
first_step: step_fixture(%{title: "first step"}, 0, pipeline, current_user),
second_step: step_fixture(%{title: "second step"}, 1, pipeline, current_user),
third_step: step_fixture(%{title: "third step"}, 2, pipeline, current_user)
]
end