fix visibility issues with multiple users

This commit is contained in:
shibao 2025-02-15 04:24:53 +00:00
parent 3e686fa199
commit 6c2aba84ef
32 changed files with 187 additions and 413 deletions

View File

@ -1,3 +1,6 @@
# v0.1.19
- Fix visibility issues with multiple users
# v0.1.18
- Update deps
- Fix content not escaping HTML properly

View File

@ -22,16 +22,16 @@ defmodule Memex.Contexts do
@spec list_contexts(search :: String.t() | nil, User.t()) :: [Context.t()]
def list_contexts(search \\ nil, user)
def list_contexts(search, %{id: user_id}) when search in [nil, ""] do
Repo.all(from c in Context, where: c.user_id == ^user_id, order_by: c.slug)
def list_contexts(search, %{id: user_id}) when user_id |> is_binary() and search in [nil, ""] do
Repo.all(from c in Context, order_by: c.slug)
end
def list_contexts(search, %{id: user_id}) when search |> is_binary() do
def list_contexts(search, %{id: user_id})
when user_id |> is_binary() and search |> is_binary() do
trimmed_search = String.trim(search)
Repo.all(
from c in Context,
where: c.user_id == ^user_id,
where:
fragment(
"search @@ websearch_to_tsquery('english', ?)",
@ -103,12 +103,8 @@ defmodule Memex.Contexts do
"""
@spec get_context!(Context.id(), User.t()) :: Context.t()
def get_context!(id, %{id: user_id}) do
Repo.one!(
from c in Context,
where: c.id == ^id,
where: c.user_id == ^user_id or c.visibility in [:public, :unlisted]
)
def get_context!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!(from c in Context, where: c.id == ^id)
end
def get_context!(id, _invalid_user) do
@ -134,12 +130,8 @@ defmodule Memex.Contexts do
"""
@spec get_context_by_slug(Context.slug(), User.t()) :: Context.t() | nil
def get_context_by_slug(slug, %{id: user_id}) do
Repo.one(
from c in Context,
where: c.slug == ^slug,
where: c.user_id == ^user_id or c.visibility in [:public, :unlisted]
)
def get_context_by_slug(slug, %{id: user_id}) when user_id |> is_binary() do
Repo.one(from c in Context, where: c.slug == ^slug)
end
def get_context_by_slug(slug, _invalid_user) do
@ -194,23 +186,16 @@ defmodule Memex.Contexts do
## Examples
iex> delete_context(%Context{user_id: 123}, %User{id: 123})
{:ok, %Context{}}
iex> delete_context(%Context{user_id: 123}, %User{role: :admin})
{:ok, %Context{}}
iex> delete_context(%Context{}, %User{id: 123})
{:ok, %Context{}}
iex> delete_context(%Context{}, nil)
{:error, %Ecto.Changeset{}}
"""
@spec delete_context(Context.t(), User.t()) ::
{:ok, Context.t()} | {:error, Context.changeset()}
def delete_context(%Context{user_id: user_id} = context, %{id: user_id}) do
context |> Repo.delete()
end
def delete_context(%Context{} = context, %{role: :admin}) do
def delete_context(%Context{} = context, %{id: user_id}) when user_id |> is_binary() do
context |> Repo.delete()
end
@ -228,13 +213,4 @@ defmodule Memex.Contexts do
def change_context(%Context{} = context, attrs \\ %{}, user) do
context |> Context.update_changeset(attrs, user)
end
@spec owner_or_admin?(Context.t(), User.t()) :: boolean()
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
def owner_or_admin?(_context, %{role: :admin}), do: true
def owner_or_admin?(_context, _other_user), do: false
@spec owner?(Context.t(), User.t()) :: boolean()
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
def owner?(_context, _other_user), do: false
end

View File

@ -63,8 +63,9 @@ defmodule Memex.Contexts.Context do
end
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = note, attrs, %User{id: user_id}) do
note
def update_changeset(%__MODULE__{} = context, attrs, %User{id: user_id})
when user_id |> is_binary() do
context
|> cast(attrs, [:slug, :content, :tags, :visibility])
|> cast_tags_string(attrs)
|> validate_format(:slug, ~r/^[\p{L}\p{N}\-]+$/,

View File

@ -31,7 +31,6 @@ defmodule Memex.Notes do
Repo.all(
from n in Note,
where: n.user_id == ^user_id,
where:
fragment(
"search @@ websearch_to_tsquery('english', ?)",
@ -102,12 +101,8 @@ defmodule Memex.Notes do
"""
@spec get_note!(Note.id(), User.t()) :: Note.t()
def get_note!(id, %{id: user_id}) do
Repo.one!(
from n in Note,
where: n.id == ^id,
where: n.user_id == ^user_id or n.visibility in [:public, :unlisted]
)
def get_note!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!(from n in Note, where: n.id == ^id)
end
def get_note!(id, _invalid_user) do
@ -133,12 +128,8 @@ defmodule Memex.Notes do
"""
@spec get_note_by_slug(Note.slug(), User.t()) :: Note.t() | nil
def get_note_by_slug(slug, %{id: user_id}) do
Repo.one(
from n in Note,
where: n.slug == ^slug,
where: n.user_id == ^user_id or n.visibility in [:public, :unlisted]
)
def get_note_by_slug(slug, %{id: user_id}) when user_id |> is_binary() do
Repo.one(from n in Note, where: n.slug == ^slug)
end
def get_note_by_slug(slug, _invalid_user) do
@ -192,22 +183,15 @@ defmodule Memex.Notes do
## Examples
iex> delete_note(%Note{user_id: 123}, %User{id: 123})
{:ok, %Note{}}
iex> delete_note(%Note{}, %User{role: :admin})
{:ok, %Note{}}
iex> delete_note(%Note{}, %User{id: 123})
{:ok, %Note{}}
iex> delete_note(%Note{}, nil)
{:error, %Ecto.Changeset{}}
"""
@spec delete_note(Note.t(), User.t()) :: {:ok, Note.t()} | {:error, Note.changeset()}
def delete_note(%Note{user_id: user_id} = note, %{id: user_id}) do
note |> Repo.delete()
end
def delete_note(%Note{} = note, %{role: :admin}) do
def delete_note(%Note{} = note, %{id: user_id}) when user_id |> is_binary() do
note |> Repo.delete()
end
@ -228,13 +212,4 @@ defmodule Memex.Notes do
def change_note(%Note{} = note, attrs \\ %{}, user) do
note |> Note.update_changeset(attrs, user)
end
@spec owner_or_admin?(Note.t(), User.t()) :: boolean()
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
def owner_or_admin?(_context, %{role: :admin}), do: true
def owner_or_admin?(_context, _other_user), do: false
@spec owner?(Note.t(), User.t()) :: boolean()
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
def owner?(_context, _other_user), do: false
end

View File

@ -62,7 +62,8 @@ defmodule Memex.Notes.Note do
end
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = note, attrs, %User{id: user_id}) do
def update_changeset(%__MODULE__{} = note, attrs, %User{id: user_id})
when user_id |> is_binary() do
note
|> cast(attrs, [:slug, :content, :tags, :visibility])
|> cast_tags_string(attrs)

View File

@ -22,16 +22,17 @@ defmodule Memex.Pipelines do
@spec list_pipelines(search :: String.t() | nil, User.t()) :: [Pipeline.t()]
def list_pipelines(search \\ nil, user)
def list_pipelines(search, %{id: user_id}) when search in [nil, ""] do
Repo.all(from p in Pipeline, where: p.user_id == ^user_id, order_by: p.slug)
def list_pipelines(search, %{id: user_id})
when user_id |> is_binary() and search in [nil, ""] do
Repo.all(from p in Pipeline, order_by: p.slug)
end
def list_pipelines(search, %{id: user_id}) when search |> is_binary() do
def list_pipelines(search, %{id: user_id})
when user_id |> is_binary() and search |> is_binary() do
trimmed_search = String.trim(search)
Repo.all(
from p in Pipeline,
where: p.user_id == ^user_id,
where:
fragment(
"search @@ websearch_to_tsquery('english', ?)",
@ -102,12 +103,8 @@ defmodule Memex.Pipelines do
"""
@spec get_pipeline!(Pipeline.id(), User.t()) :: Pipeline.t()
def get_pipeline!(id, %{id: user_id}) do
Repo.one!(
from p in Pipeline,
where: p.id == ^id,
where: p.user_id == ^user_id or p.visibility in [:public, :unlisted]
)
def get_pipeline!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!(from p in Pipeline, where: p.id == ^id)
end
def get_pipeline!(id, _invalid_user) do
@ -133,12 +130,8 @@ defmodule Memex.Pipelines do
"""
@spec get_pipeline_by_slug(Pipeline.slug(), User.t()) :: Pipeline.t() | nil
def get_pipeline_by_slug(slug, %{id: user_id}) do
Repo.one(
from p in Pipeline,
where: p.slug == ^slug,
where: p.user_id == ^user_id or p.visibility in [:public, :unlisted]
)
def get_pipeline_by_slug(slug, %{id: user_id}) when user_id |> is_binary() do
Repo.one(from p in Pipeline, where: p.slug == ^slug)
end
def get_pipeline_by_slug(slug, _invalid_user) do
@ -193,23 +186,16 @@ defmodule Memex.Pipelines do
## Examples
iex> delete_pipeline(%Pipeline{user_id: 123}, %User{id: 123})
{:ok, %Pipeline{}}
iex> delete_pipeline(%Pipeline{}, %User{role: :admin})
{:ok, %Pipeline{}}
iex> delete_pipeline(%Pipeline{}, %User{id: 123})
{:ok, %Pipeline{}}
iex> delete_pipeline(%Pipeline{}, nil)
{:error, %Ecto.Changeset{}}
"""
@spec delete_pipeline(Pipeline.t(), User.t()) ::
{:ok, Pipeline.t()} | {:error, Pipeline.changeset()}
def delete_pipeline(%Pipeline{user_id: user_id} = pipeline, %{id: user_id}) do
pipeline |> Repo.delete()
end
def delete_pipeline(%Pipeline{} = pipeline, %{role: :admin}) do
def delete_pipeline(%Pipeline{} = pipeline, %{id: user_id}) when user_id |> is_binary() do
pipeline |> Repo.delete()
end
@ -230,13 +216,4 @@ defmodule Memex.Pipelines do
def change_pipeline(%Pipeline{} = pipeline, attrs \\ %{}, user) do
pipeline |> Pipeline.update_changeset(attrs, user)
end
@spec owner_or_admin?(Pipeline.t(), User.t()) :: boolean()
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
def owner_or_admin?(_context, %{role: :admin}), do: true
def owner_or_admin?(_context, _other_user), do: false
@spec owner?(Pipeline.t(), User.t()) :: boolean()
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
def owner?(_context, _other_user), do: false
end

View File

@ -65,7 +65,8 @@ defmodule Memex.Pipelines.Pipeline do
end
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
def update_changeset(%{user_id: user_id} = pipeline, attrs, %User{id: user_id}) do
def update_changeset(%__MODULE__{} = pipeline, attrs, %User{id: user_id})
when user_id |> is_binary() do
pipeline
|> cast(attrs, [:slug, :description, :tags, :visibility])
|> cast_tags_string(attrs)

View File

@ -44,9 +44,12 @@ defmodule Memex.Pipelines.Steps.Step do
@doc false
@spec create_changeset(attrs :: map(), position :: non_neg_integer(), Pipeline.t(), User.t()) ::
changeset()
def create_changeset(attrs, position, %Pipeline{id: pipeline_id, user_id: user_id}, %User{
id: user_id
}) do
def create_changeset(
attrs,
position,
%Pipeline{id: pipeline_id, user_id: user_id},
%User{id: user_id}
) do
%__MODULE__{}
|> cast(attrs, [:title, :content])
|> change(pipeline_id: pipeline_id, user_id: user_id, position: position)
@ -55,22 +58,16 @@ defmodule Memex.Pipelines.Steps.Step do
@spec update_changeset(t(), attrs :: map(), User.t()) ::
changeset()
def update_changeset(
%{user_id: user_id} = step,
attrs,
%User{id: user_id}
) do
def update_changeset(%__MODULE__{} = step, attrs, %User{id: user_id})
when user_id |> is_binary() do
step
|> cast(attrs, [:title, :content])
|> validate_required([:title, :user_id, :position])
end
@spec position_changeset(t(), position :: non_neg_integer(), User.t()) :: changeset()
def position_changeset(
%{user_id: user_id} = step,
position,
%User{id: user_id}
) do
def position_changeset(%__MODULE__{} = step, position, %User{id: user_id})
when user_id |> is_binary() do
step
|> change(position: position)
|> validate_required([:title, :user_id, :position])

View File

@ -21,11 +21,10 @@ defmodule Memex.Pipelines.Steps do
"""
@spec list_steps(Pipeline.t(), User.t()) :: [Step.t()]
def list_steps(%{id: pipeline_id}, %{id: user_id}) do
def list_steps(%{id: pipeline_id}, %{id: user_id}) when user_id |> is_binary() do
Repo.all(
from s in Step,
where: s.pipeline_id == ^pipeline_id,
where: s.user_id == ^user_id,
order_by: s.position
)
end
@ -62,8 +61,8 @@ defmodule Memex.Pipelines.Steps do
"""
@spec get_step!(Step.id(), User.t()) :: Step.t()
def get_step!(id, %{id: user_id}) do
Repo.one!(from n in Step, where: n.id == ^id, where: n.user_id == ^user_id)
def get_step!(id, %{id: user_id}) when user_id |> is_binary() do
Repo.one!(from n in Step, where: n.id == ^id)
end
def get_step!(id, _invalid_user) do
@ -119,22 +118,15 @@ defmodule Memex.Pipelines.Steps do
## Examples
iex> delete_step(%Step{user_id: 123}, %User{id: 123})
{:ok, %Step{}}
iex> delete_step(%Step{}, %User{role: :admin})
{:ok, %Step{}}
iex> delete_step(%Step{}, %User{id: 123})
{:ok, %Step{}}
iex> delete_step(%Step{}, nil)
{:error, %Ecto.Changeset{}}
"""
@spec delete_step(Step.t(), User.t()) :: {:ok, Step.t()} | {:error, Step.changeset()}
def delete_step(%Step{user_id: user_id} = step, %{id: user_id}) do
delete_step(step)
end
def delete_step(%Step{} = step, %{role: :admin}) do
def delete_step(%Step{} = step, %{id: user_id}) when user_id |> is_binary() do
delete_step(step)
end
@ -181,10 +173,11 @@ defmodule Memex.Pipelines.Steps do
def reorder_step(%Step{position: 0} = step, :up, _user), do: {:error, step}
def reorder_step(
%Step{position: position, pipeline_id: pipeline_id, user_id: user_id} = step,
%Step{position: position, pipeline_id: pipeline_id} = step,
:up,
%{id: user_id} = user
) do
)
when user_id |> is_binary() do
Multi.new()
|> Multi.update_all(
:reorder_steps,
@ -207,10 +200,11 @@ defmodule Memex.Pipelines.Steps do
end
def reorder_step(
%Step{pipeline_id: pipeline_id, position: position, user_id: user_id} = step,
%Step{pipeline_id: pipeline_id, position: position} = step,
:down,
%{id: user_id} = user
) do
)
when user_id |> is_binary() do
Multi.new()
|> Multi.one(
:step_count,

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl">
<div class="flex flex-col justify-center items-start mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= gettext("contexts") %>
</h1>
@ -9,7 +9,7 @@
as={:search}
phx-change="search"
phx-submit="search"
class="self-stretch flex flex-col items-stretch"
class="flex flex-col items-stretch self-stretch"
>
<%= text_input(f, :search_term,
class: "input input-primary",
@ -33,14 +33,14 @@
>
<:actions :let={context}>
<.link
:if={Contexts.owner?(context, @current_user)}
:if={@current_user}
patch={~p"/contexts/#{context}/edit"}
aria-label={dgettext("actions", "edit %{context_slug}", context_slug: context.slug)}
>
<%= dgettext("actions", "edit") %>
</.link>
<.link
:if={Contexts.owner_or_admin?(context, @current_user)}
:if={@current_user}
href="#"
phx-click="delete"
phx-value-id={context.id}

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl">
<div class="flex flex-col justify-center items-stretch mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= @context.slug %>
</h1>
@ -15,16 +15,12 @@
<%= gettext("Visibility: %{visibility}", visibility: @context.visibility) %>
</p>
<div class="self-end flex space-x-4">
<.link
:if={Contexts.owner?(@context, @current_user)}
class="btn btn-primary"
patch={~p"/context/#{@context}/edit"}
>
<div class="flex self-end space-x-4">
<.link :if={@current_user} class="btn btn-primary" patch={~p"/context/#{@context}/edit"}>
<%= dgettext("actions", "edit") %>
</.link>
<button
:if={Contexts.owner_or_admin?(@context, @current_user)}
:if={@current_user}
type="button"
class="btn btn-primary"
phx-click="delete"

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl">
<div class="flex flex-col justify-center items-start mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= gettext("notes") %>
</h1>
@ -9,7 +9,7 @@
as={:search}
phx-change="search"
phx-submit="search"
class="self-stretch flex flex-col items-stretch"
class="flex flex-col items-stretch self-stretch"
>
<%= text_input(f, :search_term,
class: "input input-primary",
@ -33,14 +33,14 @@
>
<:actions :let={note}>
<.link
:if={Notes.owner?(note, @current_user)}
:if={@current_user}
patch={~p"/notes/#{note}/edit"}
aria-label={dgettext("actions", "edit %{note_slug}", note_slug: note.slug)}
>
<%= dgettext("actions", "edit") %>
</.link>
<.link
:if={Notes.owner_or_admin?(note, @current_user)}
:if={@current_user}
href="#"
phx-click="delete"
phx-value-id={note.id}

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl">
<div class="flex flex-col justify-center items-stretch mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= @note.slug %>
</h1>
@ -15,16 +15,12 @@
<%= gettext("Visibility: %{visibility}", visibility: @note.visibility) %>
</p>
<div class="self-end flex space-x-4">
<.link
:if={Notes.owner?(@note, @current_user)}
class="btn btn-primary"
patch={~p"/note/#{@note}/edit"}
>
<div class="flex self-end space-x-4">
<.link :if={@current_user} class="btn btn-primary" patch={~p"/note/#{@note}/edit"}>
<%= dgettext("actions", "edit") %>
</.link>
<button
:if={Notes.owner_or_admin?(@note, @current_user)}
:if={@current_user}
type="button"
class="btn btn-primary"
phx-click="delete"

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-start space-y-4 max-w-3xl">
<div class="flex flex-col justify-center items-start mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= gettext("pipelines") %>
</h1>
@ -9,7 +9,7 @@
as={:search}
phx-change="search"
phx-submit="search"
class="self-stretch flex flex-col items-stretch"
class="flex flex-col items-stretch self-stretch"
>
<%= text_input(f, :search_term,
class: "input input-primary",
@ -33,14 +33,14 @@
>
<:actions :let={pipeline}>
<.link
:if={Pipelines.owner?(pipeline, @current_user)}
:if={@current_user}
patch={~p"/pipelines/#{pipeline}/edit"}
aria-label={dgettext("actions", "edit %{pipeline_slug}", pipeline_slug: pipeline.slug)}
>
<%= dgettext("actions", "edit") %>
</.link>
<.link
:if={Pipelines.owner_or_admin?(pipeline, @current_user)}
:if={@current_user}
href="#"
phx-click="delete"
phx-value-id={pipeline.id}

View File

@ -1,4 +1,4 @@
<div class="mx-auto flex flex-col justify-center items-stretch space-y-4 max-w-3xl">
<div class="flex flex-col justify-center items-stretch mx-auto space-y-4 max-w-3xl">
<h1 class="text-xl">
<%= @pipeline.slug %>
</h1>
@ -15,16 +15,12 @@
<%= gettext("Visibility: %{visibility}", visibility: @pipeline.visibility) %>
</p>
<div class="pb-4 self-end flex space-x-4">
<.link
:if={Pipelines.owner?(@pipeline, @current_user)}
class="btn btn-primary"
patch={~p"/pipeline/#{@pipeline}/edit"}
>
<div class="flex self-end pb-4 space-x-4">
<.link :if={@current_user} class="btn btn-primary" patch={~p"/pipeline/#{@pipeline}/edit"}>
<%= dgettext("actions", "edit") %>
</.link>
<button
:if={Pipelines.owner_or_admin?(@pipeline, @current_user)}
:if={@current_user}
type="button"
class="btn btn-primary"
phx-click="delete"
@ -37,7 +33,7 @@
<hr class="hr" />
<h2 class="pt-2 self-center text-lg">
<h2 class="self-center pt-2 text-lg">
<%= gettext("steps:") %>
</h2>
@ -52,29 +48,29 @@
<%= gettext("%{position}. %{title}", position: position + 1, title: title) %>
</h3>
<%= if Pipelines.owner?(@pipeline, @current_user) do %>
<%= if @current_user do %>
<div class="flex justify-between items-center space-x-4">
<%= if position <= 0 do %>
<i class="fas text-xl fa-chevron-up cursor-not-allowed opacity-25"></i>
<i class="text-xl opacity-25 cursor-not-allowed fas fa-chevron-up"></i>
<% else %>
<button
type="button"
class="cursor-pointer flex justify-center items-center"
class="flex justify-center items-center cursor-pointer"
phx-click="reorder_step"
phx-value-direction="up"
phx-value-step-id={step_id}
aria-label={dgettext("actions", "move %{step_title} up", step_title: step.title)}
>
<i class="fas text-xl fa-chevron-up"></i>
<i class="text-xl fas fa-chevron-up"></i>
</button>
<% end %>
<%= if position >= length(@steps) - 1 do %>
<i class="fas text-xl fa-chevron-down cursor-not-allowed opacity-25"></i>
<i class="text-xl opacity-25 cursor-not-allowed fas fa-chevron-down"></i>
<% else %>
<button
type="button"
class="cursor-pointer flex justify-center items-center"
class="flex justify-center items-center cursor-pointer"
phx-click="reorder_step"
phx-value-direction="down"
phx-value-step-id={step_id}
@ -82,7 +78,7 @@
dgettext("actions", "move %{step_title} down", step_title: step.title)
}
>
<i class="fas text-xl fa-chevron-down"></i>
<i class="text-xl fas fa-chevron-down"></i>
</button>
<% end %>
@ -113,7 +109,7 @@
<% end %>
<.link
:if={Pipelines.owner?(@pipeline, @current_user)}
:if={@current_user}
class="self-end btn btn-primary"
patch={~p"/pipeline/#{@pipeline}/add_step"}
>

View File

@ -4,7 +4,7 @@ defmodule Memex.MixProject do
def project do
[
app: :memex,
version: "0.1.18",
version: "0.1.19",
elixir: "1.18.1",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,

View File

@ -40,12 +40,12 @@ msgid "create invite"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:50
#: lib/memex_web/live/context_live/show.html.heex:34
#: lib/memex_web/live/context_live/show.html.heex:30
#: lib/memex_web/live/note_live/index.html.heex:50
#: lib/memex_web/live/note_live/show.html.heex:34
#: lib/memex_web/live/note_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/index.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:34
#: lib/memex_web/live/pipeline_live/show.html.heex:105
#: lib/memex_web/live/pipeline_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/show.html.heex:101
#, elixir-autogen, elixir-format
msgid "delete"
msgstr ""
@ -56,12 +56,12 @@ msgid "delete user"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:40
#: lib/memex_web/live/context_live/show.html.heex:24
#: lib/memex_web/live/context_live/show.html.heex:20
#: lib/memex_web/live/note_live/index.html.heex:40
#: lib/memex_web/live/note_live/show.html.heex:24
#: lib/memex_web/live/note_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/index.html.heex:40
#: lib/memex_web/live/pipeline_live/show.html.heex:24
#: lib/memex_web/live/pipeline_live/show.html.heex:94
#: lib/memex_web/live/pipeline_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/show.html.heex:90
#, elixir-autogen, elixir-format
msgid "edit"
msgstr ""
@ -112,7 +112,7 @@ msgstr ""
msgid "save"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:120
#: lib/memex_web/live/pipeline_live/show.html.heex:116
#, elixir-autogen, elixir-format
msgid "add step"
msgstr ""
@ -145,24 +145,24 @@ msgid "copy invite link for %{invite_name}"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:48
#: lib/memex_web/live/context_live/show.html.heex:32
#: lib/memex_web/live/context_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{context_slug}"
msgstr ""
#: lib/memex_web/live/note_live/index.html.heex:48
#: lib/memex_web/live/note_live/show.html.heex:32
#: lib/memex_web/live/note_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{note_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/index.html.heex:49
#: lib/memex_web/live/pipeline_live/show.html.heex:32
#: lib/memex_web/live/pipeline_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{pipeline_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:103
#: lib/memex_web/live/pipeline_live/show.html.heex:99
#, elixir-autogen, elixir-format
msgid "delete %{step_title}"
msgstr ""
@ -187,7 +187,7 @@ msgstr ""
msgid "edit %{pipeline_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:92
#: lib/memex_web/live/pipeline_live/show.html.heex:88
#, elixir-autogen, elixir-format
msgid "edit %{step_title}"
msgstr ""
@ -197,12 +197,12 @@ msgstr ""
msgid "edit invite for %{invite_name}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:82
#: lib/memex_web/live/pipeline_live/show.html.heex:78
#, elixir-autogen, elixir-format
msgid "move %{step_title} down"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:66
#: lib/memex_web/live/pipeline_live/show.html.heex:62
#, elixir-autogen, elixir-format
msgid "move %{step_title} up"
msgstr ""

View File

@ -40,12 +40,12 @@ msgid "create invite"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:50
#: lib/memex_web/live/context_live/show.html.heex:34
#: lib/memex_web/live/context_live/show.html.heex:30
#: lib/memex_web/live/note_live/index.html.heex:50
#: lib/memex_web/live/note_live/show.html.heex:34
#: lib/memex_web/live/note_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/index.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:34
#: lib/memex_web/live/pipeline_live/show.html.heex:105
#: lib/memex_web/live/pipeline_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/show.html.heex:101
#, elixir-autogen, elixir-format
msgid "delete"
msgstr ""
@ -56,12 +56,12 @@ msgid "delete user"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:40
#: lib/memex_web/live/context_live/show.html.heex:24
#: lib/memex_web/live/context_live/show.html.heex:20
#: lib/memex_web/live/note_live/index.html.heex:40
#: lib/memex_web/live/note_live/show.html.heex:24
#: lib/memex_web/live/note_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/index.html.heex:40
#: lib/memex_web/live/pipeline_live/show.html.heex:24
#: lib/memex_web/live/pipeline_live/show.html.heex:94
#: lib/memex_web/live/pipeline_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/show.html.heex:90
#, elixir-autogen, elixir-format
msgid "edit"
msgstr ""
@ -112,7 +112,7 @@ msgstr ""
msgid "save"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:120
#: lib/memex_web/live/pipeline_live/show.html.heex:116
#, elixir-autogen, elixir-format
msgid "add step"
msgstr ""
@ -145,24 +145,24 @@ msgid "copy invite link for %{invite_name}"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:48
#: lib/memex_web/live/context_live/show.html.heex:32
#: lib/memex_web/live/context_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{context_slug}"
msgstr ""
#: lib/memex_web/live/note_live/index.html.heex:48
#: lib/memex_web/live/note_live/show.html.heex:32
#: lib/memex_web/live/note_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{note_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/index.html.heex:49
#: lib/memex_web/live/pipeline_live/show.html.heex:32
#: lib/memex_web/live/pipeline_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{pipeline_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:103
#: lib/memex_web/live/pipeline_live/show.html.heex:99
#, elixir-autogen, elixir-format
msgid "delete %{step_title}"
msgstr ""
@ -187,7 +187,7 @@ msgstr ""
msgid "edit %{pipeline_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:92
#: lib/memex_web/live/pipeline_live/show.html.heex:88
#, elixir-autogen, elixir-format
msgid "edit %{step_title}"
msgstr ""
@ -197,12 +197,12 @@ msgstr ""
msgid "edit invite for %{invite_name}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:82
#: lib/memex_web/live/pipeline_live/show.html.heex:78
#, elixir-autogen, elixir-format
msgid "move %{step_title} down"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:66
#: lib/memex_web/live/pipeline_live/show.html.heex:62
#, elixir-autogen, elixir-format
msgid "move %{step_title} up"
msgstr ""

View File

@ -422,7 +422,7 @@ msgstr ""
msgid "what is this?"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:48
#, elixir-autogen, elixir-format
msgid "%{position}. %{title}"
msgstr ""
@ -447,12 +447,12 @@ msgstr ""
msgid "add step to %{slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:46
#: lib/memex_web/live/pipeline_live/show.html.heex:42
#, elixir-autogen, elixir-format
msgid "no steps"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:41
#: lib/memex_web/live/pipeline_live/show.html.heex:37
#, elixir-autogen, elixir-format
msgid "steps:"
msgstr ""

View File

@ -47,11 +47,11 @@ msgid "must have the @ sign and no spaces"
msgstr ""
#: lib/memex/contexts/context.ex:58
#: lib/memex/contexts/context.ex:71
#: lib/memex/contexts/context.ex:72
#: lib/memex/notes/note.ex:57
#: lib/memex/notes/note.ex:70
#: lib/memex/notes/note.ex:71
#: lib/memex/pipelines/pipeline.ex:60
#: lib/memex/pipelines/pipeline.ex:73
#: lib/memex/pipelines/pipeline.ex:74
#, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted"
msgstr ""
@ -140,9 +140,9 @@ msgstr ""
msgid "user confirmation link is invalid or it has expired."
msgstr ""
#: lib/memex/contexts/context.ex:84
#: lib/memex/notes/note.ex:83
#: lib/memex/pipelines/pipeline.ex:86
#: lib/memex/contexts/context.ex:85
#: lib/memex/notes/note.ex:84
#: lib/memex/pipelines/pipeline.ex:87
#, elixir-autogen, elixir-format, fuzzy
msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited"
msgstr ""

View File

@ -66,12 +66,12 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:47
#: lib/memex_web/live/context_live/show.html.heex:31
#: lib/memex_web/live/context_live/show.html.heex:27
#: lib/memex_web/live/note_live/index.html.heex:47
#: lib/memex_web/live/note_live/show.html.heex:31
#: lib/memex_web/live/note_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/index.html.heex:47
#: lib/memex_web/live/pipeline_live/show.html.heex:31
#: lib/memex_web/live/pipeline_live/show.html.heex:102
#: lib/memex_web/live/pipeline_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/show.html.heex:98
#, elixir-autogen, elixir-format
msgid "are you sure?"
msgstr ""

View File

@ -420,7 +420,7 @@ msgstr ""
msgid "what is this?"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:48
#, elixir-autogen, elixir-format
msgid "%{position}. %{title}"
msgstr ""
@ -445,12 +445,12 @@ msgstr ""
msgid "add step to %{slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:46
#: lib/memex_web/live/pipeline_live/show.html.heex:42
#, elixir-autogen, elixir-format
msgid "no steps"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:41
#: lib/memex_web/live/pipeline_live/show.html.heex:37
#, elixir-autogen, elixir-format
msgid "steps:"
msgstr ""

View File

@ -41,12 +41,12 @@ msgid "create invite"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:50
#: lib/memex_web/live/context_live/show.html.heex:34
#: lib/memex_web/live/context_live/show.html.heex:30
#: lib/memex_web/live/note_live/index.html.heex:50
#: lib/memex_web/live/note_live/show.html.heex:34
#: lib/memex_web/live/note_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/index.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:34
#: lib/memex_web/live/pipeline_live/show.html.heex:105
#: lib/memex_web/live/pipeline_live/show.html.heex:30
#: lib/memex_web/live/pipeline_live/show.html.heex:101
#, elixir-autogen, elixir-format
msgid "delete"
msgstr ""
@ -57,12 +57,12 @@ msgid "delete user"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:40
#: lib/memex_web/live/context_live/show.html.heex:24
#: lib/memex_web/live/context_live/show.html.heex:20
#: lib/memex_web/live/note_live/index.html.heex:40
#: lib/memex_web/live/note_live/show.html.heex:24
#: lib/memex_web/live/note_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/index.html.heex:40
#: lib/memex_web/live/pipeline_live/show.html.heex:24
#: lib/memex_web/live/pipeline_live/show.html.heex:94
#: lib/memex_web/live/pipeline_live/show.html.heex:20
#: lib/memex_web/live/pipeline_live/show.html.heex:90
#, elixir-autogen, elixir-format
msgid "edit"
msgstr ""
@ -113,7 +113,7 @@ msgstr ""
msgid "save"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:120
#: lib/memex_web/live/pipeline_live/show.html.heex:116
#, elixir-autogen, elixir-format
msgid "add step"
msgstr ""
@ -146,24 +146,24 @@ msgid "copy invite link for %{invite_name}"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:48
#: lib/memex_web/live/context_live/show.html.heex:32
#: lib/memex_web/live/context_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{context_slug}"
msgstr ""
#: lib/memex_web/live/note_live/index.html.heex:48
#: lib/memex_web/live/note_live/show.html.heex:32
#: lib/memex_web/live/note_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{note_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/index.html.heex:49
#: lib/memex_web/live/pipeline_live/show.html.heex:32
#: lib/memex_web/live/pipeline_live/show.html.heex:28
#, elixir-autogen, elixir-format
msgid "delete %{pipeline_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:103
#: lib/memex_web/live/pipeline_live/show.html.heex:99
#, elixir-autogen, elixir-format
msgid "delete %{step_title}"
msgstr ""
@ -188,7 +188,7 @@ msgstr ""
msgid "edit %{pipeline_slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:92
#: lib/memex_web/live/pipeline_live/show.html.heex:88
#, elixir-autogen, elixir-format
msgid "edit %{step_title}"
msgstr ""
@ -198,12 +198,12 @@ msgstr ""
msgid "edit invite for %{invite_name}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:82
#: lib/memex_web/live/pipeline_live/show.html.heex:78
#, elixir-autogen, elixir-format
msgid "move %{step_title} down"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:66
#: lib/memex_web/live/pipeline_live/show.html.heex:62
#, elixir-autogen, elixir-format
msgid "move %{step_title} up"
msgstr ""

View File

@ -421,7 +421,7 @@ msgstr ""
msgid "what is this?"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:52
#: lib/memex_web/live/pipeline_live/show.html.heex:48
#, elixir-autogen, elixir-format
msgid "%{position}. %{title}"
msgstr ""
@ -446,12 +446,12 @@ msgstr ""
msgid "add step to %{slug}"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:46
#: lib/memex_web/live/pipeline_live/show.html.heex:42
#, elixir-autogen, elixir-format
msgid "no steps"
msgstr ""
#: lib/memex_web/live/pipeline_live/show.html.heex:41
#: lib/memex_web/live/pipeline_live/show.html.heex:37
#, elixir-autogen, elixir-format
msgid "steps:"
msgstr ""

View File

@ -48,11 +48,11 @@ msgid "must have the @ sign and no spaces"
msgstr ""
#: lib/memex/contexts/context.ex:58
#: lib/memex/contexts/context.ex:71
#: lib/memex/contexts/context.ex:72
#: lib/memex/notes/note.ex:57
#: lib/memex/notes/note.ex:70
#: lib/memex/notes/note.ex:71
#: lib/memex/pipelines/pipeline.ex:60
#: lib/memex/pipelines/pipeline.ex:73
#: lib/memex/pipelines/pipeline.ex:74
#, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted"
msgstr ""
@ -141,9 +141,9 @@ msgstr ""
msgid "user confirmation link is invalid or it has expired."
msgstr ""
#: lib/memex/contexts/context.ex:84
#: lib/memex/notes/note.ex:83
#: lib/memex/pipelines/pipeline.ex:86
#: lib/memex/contexts/context.ex:85
#: lib/memex/notes/note.ex:84
#: lib/memex/pipelines/pipeline.ex:87
#, elixir-autogen, elixir-format, fuzzy
msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited"
msgstr ""

View File

@ -67,12 +67,12 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:47
#: lib/memex_web/live/context_live/show.html.heex:31
#: lib/memex_web/live/context_live/show.html.heex:27
#: lib/memex_web/live/note_live/index.html.heex:47
#: lib/memex_web/live/note_live/show.html.heex:31
#: lib/memex_web/live/note_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/index.html.heex:47
#: lib/memex_web/live/pipeline_live/show.html.heex:31
#: lib/memex_web/live/pipeline_live/show.html.heex:102
#: lib/memex_web/live/pipeline_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/show.html.heex:98
#, elixir-autogen, elixir-format
msgid "are you sure?"
msgstr ""

View File

@ -47,11 +47,11 @@ msgid "must have the @ sign and no spaces"
msgstr ""
#: lib/memex/contexts/context.ex:58
#: lib/memex/contexts/context.ex:71
#: lib/memex/contexts/context.ex:72
#: lib/memex/notes/note.ex:57
#: lib/memex/notes/note.ex:70
#: lib/memex/notes/note.ex:71
#: lib/memex/pipelines/pipeline.ex:60
#: lib/memex/pipelines/pipeline.ex:73
#: lib/memex/pipelines/pipeline.ex:74
#, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted"
msgstr ""
@ -140,9 +140,9 @@ msgstr ""
msgid "user confirmation link is invalid or it has expired."
msgstr ""
#: lib/memex/contexts/context.ex:84
#: lib/memex/notes/note.ex:83
#: lib/memex/pipelines/pipeline.ex:86
#: lib/memex/contexts/context.ex:85
#: lib/memex/notes/note.ex:84
#: lib/memex/pipelines/pipeline.ex:87
#, elixir-autogen, elixir-format
msgid "invalid format: only numbers, letters and hyphen are accepted. tags must be comma or space delimited"
msgstr ""

View File

@ -66,12 +66,12 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
msgstr ""
#: lib/memex_web/live/context_live/index.html.heex:47
#: lib/memex_web/live/context_live/show.html.heex:31
#: lib/memex_web/live/context_live/show.html.heex:27
#: lib/memex_web/live/note_live/index.html.heex:47
#: lib/memex_web/live/note_live/show.html.heex:31
#: lib/memex_web/live/note_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/index.html.heex:47
#: lib/memex_web/live/pipeline_live/show.html.heex:31
#: lib/memex_web/live/pipeline_live/show.html.heex:102
#: lib/memex_web/live/pipeline_live/show.html.heex:27
#: lib/memex_web/live/pipeline_live/show.html.heex:98
#, elixir-autogen, elixir-format
msgid "are you sure?"
msgstr ""

View File

@ -25,10 +25,6 @@ defmodule Memex.ContextsTest do
%{slug: "chickens", content: "bananas stuff", tags: ["life", "decisions"]}
|> context_fixture(user)
_shouldnt_return =
%{slug: "dog", content: "banana treat stuff", visibility: :private}
|> context_fixture(user_fixture())
# slug
assert Contexts.list_contexts("dog", user) == [context_a]
assert Contexts.list_contexts("dogs", user) == [context_a]
@ -72,15 +68,6 @@ defmodule Memex.ContextsTest do
}
|> context_fixture(user)
_shouldnt_return =
%{
slug: "dog",
content: "treats bananas stuff",
tags: ["home", "life", "decisions"],
visibility: :private
}
|> context_fixture(user)
# slug
assert Contexts.list_public_contexts("dog") == [context_a]
assert Contexts.list_public_contexts("dogs") == [context_a]
@ -110,21 +97,6 @@ defmodule Memex.ContextsTest do
assert Contexts.get_context!(context.id, user) == context
end
test "get_context!/1 only returns unlisted or public contexts for other users", %{user: user} do
another_user = user_fixture()
context = context_fixture(%{visibility: :public}, another_user)
assert Contexts.get_context!(context.id, user) == context
context = context_fixture(%{visibility: :unlisted}, another_user)
assert Contexts.get_context!(context.id, user) == context
context = context_fixture(%{visibility: :private}, another_user)
assert_raise Ecto.NoResultsError, fn ->
Contexts.get_context!(context.id, user)
end
end
test "get_context_by_slug/1 returns the context with given id", %{user: user} do
context = context_fixture(%{slug: "a", visibility: :public}, user)
assert Contexts.get_context_by_slug("a", user) == context
@ -136,20 +108,6 @@ defmodule Memex.ContextsTest do
assert Contexts.get_context_by_slug("c", user) == context
end
test "get_context_by_slug/1 only returns unlisted or public contexts for other users", %{
user: user
} do
another_user = user_fixture()
context = context_fixture(%{slug: "a", visibility: :public}, another_user)
assert Contexts.get_context_by_slug("a", user) == context
context = context_fixture(%{slug: "b", visibility: :unlisted}, another_user)
assert Contexts.get_context_by_slug("b", user) == context
context_fixture(%{slug: "c", visibility: :private}, another_user)
assert Contexts.get_context_by_slug("c", user) |> is_nil()
end
test "create_context/1 with valid data creates a context", %{user: user} do
valid_attrs = %{
content: "some content",

View File

@ -14,7 +14,6 @@ defmodule Memex.NotesTest do
note_a = note_fixture(%{slug: "a", visibility: :public}, user)
note_b = note_fixture(%{slug: "b", visibility: :unlisted}, user)
note_c = note_fixture(%{slug: "c", visibility: :private}, user)
_shouldnt_return = note_fixture(%{visibility: :private}, user_fixture())
assert Notes.list_notes(user) == [note_a, note_b, note_c]
end
@ -27,10 +26,6 @@ defmodule Memex.NotesTest do
%{slug: "chickens", content: "bananas stuff", tags: ["life", "decisions"]}
|> note_fixture(user)
_shouldnt_return =
%{slug: "dog", content: "banana treat stuff", visibility: :private}
|> note_fixture(user_fixture())
# slug
assert Notes.list_notes("dog", user) == [note_a]
assert Notes.list_notes("dogs", user) == [note_a]
@ -74,15 +69,6 @@ defmodule Memex.NotesTest do
}
|> note_fixture(user)
_shouldnt_return =
%{
slug: "dog",
content: "treats bananas stuff",
tags: ["home", "life", "decisions"],
visibility: :private
}
|> note_fixture(user)
# slug
assert Notes.list_public_notes("dog") == [note_a]
assert Notes.list_public_notes("dogs") == [note_a]
@ -112,21 +98,6 @@ defmodule Memex.NotesTest do
assert Notes.get_note!(note.id, user) == note
end
test "get_note!/1 only returns unlisted or public notes for other users", %{user: user} do
another_user = user_fixture()
note = note_fixture(%{visibility: :public}, another_user)
assert Notes.get_note!(note.id, user) == note
note = note_fixture(%{visibility: :unlisted}, another_user)
assert Notes.get_note!(note.id, user) == note
note = note_fixture(%{visibility: :private}, another_user)
assert_raise Ecto.NoResultsError, fn ->
Notes.get_note!(note.id, user)
end
end
test "get_note_by_slug/1 returns the note with given id", %{user: user} do
note = note_fixture(%{slug: "a", visibility: :public}, user)
assert Notes.get_note_by_slug("a", user) == note
@ -138,20 +109,6 @@ defmodule Memex.NotesTest do
assert Notes.get_note_by_slug("c", user) == note
end
test "get_note_by_slug/1 only returns unlisted or public notes for other users", %{
user: user
} do
another_user = user_fixture()
note = note_fixture(%{slug: "a", visibility: :public}, another_user)
assert Notes.get_note_by_slug("a", user) == note
note = note_fixture(%{slug: "b", visibility: :unlisted}, another_user)
assert Notes.get_note_by_slug("b", user) == note
note_fixture(%{slug: "c", visibility: :private}, another_user)
assert Notes.get_note_by_slug("c", user) |> is_nil()
end
test "create_note/1 with valid data creates a note", %{user: user} do
valid_attrs = %{
content: "some content",

View File

@ -25,10 +25,6 @@ defmodule Memex.PipelinesTest do
%{slug: "chickens", description: "bananas stuff", tags: ["life", "decisions"]}
|> pipeline_fixture(user)
_shouldnt_return =
%{slug: "dog", description: "banana treat stuff", visibility: :private}
|> pipeline_fixture(user_fixture())
# slug
assert Pipelines.list_pipelines("dog", user) == [pipeline_a]
assert Pipelines.list_pipelines("dogs", user) == [pipeline_a]
@ -72,15 +68,6 @@ defmodule Memex.PipelinesTest do
}
|> pipeline_fixture(user)
_shouldnt_return =
%{
slug: "dog",
description: "treats bananas stuff",
tags: ["home", "life", "decisions"],
visibility: :private
}
|> pipeline_fixture(user)
# slug
assert Pipelines.list_public_pipelines("dog") == [pipeline_a]
assert Pipelines.list_public_pipelines("dogs") == [pipeline_a]
@ -110,23 +97,6 @@ defmodule Memex.PipelinesTest do
assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline
end
test "get_pipeline!/1 only returns unlisted or public pipelines for other users", %{
user: user
} do
another_user = user_fixture()
pipeline = pipeline_fixture(%{visibility: :public}, another_user)
assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline
pipeline = pipeline_fixture(%{visibility: :unlisted}, another_user)
assert Pipelines.get_pipeline!(pipeline.id, user) == pipeline
pipeline = pipeline_fixture(%{visibility: :private}, another_user)
assert_raise Ecto.NoResultsError, fn ->
Pipelines.get_pipeline!(pipeline.id, user)
end
end
test "get_pipeline_by_slug/1 returns the pipeline with given id", %{user: user} do
pipeline = pipeline_fixture(%{slug: "a", visibility: :public}, user)
assert Pipelines.get_pipeline_by_slug("a", user) == pipeline
@ -138,20 +108,6 @@ defmodule Memex.PipelinesTest do
assert Pipelines.get_pipeline_by_slug("c", user) == pipeline
end
test "get_pipeline_by_slug/1 only returns unlisted or public pipelines for other users", %{
user: user
} do
another_user = user_fixture()
pipeline = pipeline_fixture(%{slug: "a", visibility: :public}, another_user)
assert Pipelines.get_pipeline_by_slug("a", user) == pipeline
pipeline = pipeline_fixture(%{slug: "b", visibility: :unlisted}, another_user)
assert Pipelines.get_pipeline_by_slug("b", user) == pipeline
pipeline_fixture(%{slug: "c", visibility: :private}, another_user)
assert Pipelines.get_pipeline_by_slug("c", user) |> is_nil()
end
test "create_pipeline/1 with valid data creates a pipeline", %{user: user} do
valid_attrs = %{
description: "some description",

View File

@ -25,16 +25,6 @@ defmodule Memex.StepsTest do
assert Steps.get_step!(step.id, user) == step
end
test "get_step!/2 only returns unlisted or public steps for other users", %{user: user} do
another_user = user_fixture()
another_pipeline = pipeline_fixture(another_user)
step = step_fixture(0, another_pipeline, another_user)
assert_raise Ecto.NoResultsError, fn ->
Steps.get_step!(step.id, user)
end
end
test "create_step/4 with valid data creates a step", %{pipeline: pipeline, user: user} do
valid_attrs = %{
content: "some content",