Merge branch 'develop' into mutes-blocks-pagination
This commit is contained in:
commit
76c4e80e5a
85 changed files with 420 additions and 320 deletions
166
test/credo/check/consistency/file_location.ex
Normal file
166
test/credo/check/consistency/file_location.ex
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Originally taken from
|
||||
# https://github.com/VeryBigThings/elixir_common/blob/master/lib/vbt/credo/check/consistency/file_location.ex
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Credo.Check.Consistency.FileLocation do
|
||||
@moduledoc false
|
||||
|
||||
# credo:disable-for-this-file Credo.Check.Readability.Specs
|
||||
|
||||
@checkdoc """
|
||||
File location should follow the namespace hierarchy of the module it defines.
|
||||
|
||||
Examples:
|
||||
|
||||
- `lib/my_system.ex` should define the `MySystem` module
|
||||
- `lib/my_system/accounts.ex` should define the `MySystem.Accounts` module
|
||||
"""
|
||||
@explanation [warning: @checkdoc]
|
||||
|
||||
@special_namespaces [
|
||||
"controllers",
|
||||
"views",
|
||||
"operations",
|
||||
"channels"
|
||||
]
|
||||
|
||||
# `use Credo.Check` required that module attributes are already defined, so we need
|
||||
# to place these attributes
|
||||
# before use/alias expressions.
|
||||
# credo:disable-for-next-line VBT.Credo.Check.Consistency.ModuleLayout
|
||||
use Credo.Check, category: :warning, base_priority: :high
|
||||
|
||||
alias Credo.Code
|
||||
|
||||
def run(source_file, params \\ []) do
|
||||
case verify(source_file, params) do
|
||||
:ok ->
|
||||
[]
|
||||
|
||||
{:error, module, expected_file} ->
|
||||
error(IssueMeta.for(source_file, params), module, expected_file)
|
||||
end
|
||||
end
|
||||
|
||||
defp verify(source_file, params) do
|
||||
source_file.filename
|
||||
|> Path.relative_to_cwd()
|
||||
|> verify(Code.ast(source_file), params)
|
||||
end
|
||||
|
||||
@doc false
|
||||
def verify(relative_path, ast, params) do
|
||||
if verify_path?(relative_path, params),
|
||||
do: ast |> main_module() |> verify_module(relative_path, params),
|
||||
else: :ok
|
||||
end
|
||||
|
||||
defp verify_path?(relative_path, params) do
|
||||
case Path.split(relative_path) do
|
||||
["lib" | _] -> not exclude?(relative_path, params)
|
||||
["test", "support" | _] -> false
|
||||
["test", "test_helper.exs"] -> false
|
||||
["test" | _] -> not exclude?(relative_path, params)
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
|
||||
defp exclude?(relative_path, params) do
|
||||
params
|
||||
|> Keyword.get(:exclude, [])
|
||||
|> Enum.any?(&String.starts_with?(relative_path, &1))
|
||||
end
|
||||
|
||||
defp main_module(ast) do
|
||||
{_ast, modules} = Macro.prewalk(ast, [], &traverse/2)
|
||||
Enum.at(modules, -1)
|
||||
end
|
||||
|
||||
defp traverse({:defmodule, _meta, args}, modules) do
|
||||
[{:__aliases__, _, name_parts}, _module_body] = args
|
||||
{args, [Module.concat(name_parts) | modules]}
|
||||
end
|
||||
|
||||
defp traverse(ast, state), do: {ast, state}
|
||||
|
||||
# empty file - shouldn't really happen, but we'll let it through
|
||||
defp verify_module(nil, _relative_path, _params), do: :ok
|
||||
|
||||
defp verify_module(main_module, relative_path, params) do
|
||||
parsed_path = parsed_path(relative_path, params)
|
||||
|
||||
expected_file =
|
||||
expected_file_base(parsed_path.root, main_module) <>
|
||||
Path.extname(parsed_path.allowed)
|
||||
|
||||
cond do
|
||||
expected_file == parsed_path.allowed ->
|
||||
:ok
|
||||
|
||||
special_namespaces?(parsed_path.allowed) ->
|
||||
original_path = parsed_path.allowed
|
||||
|
||||
namespace =
|
||||
Enum.find(@special_namespaces, original_path, fn namespace ->
|
||||
String.contains?(original_path, namespace)
|
||||
end)
|
||||
|
||||
allowed = String.replace(original_path, "/" <> namespace, "")
|
||||
|
||||
if expected_file == allowed,
|
||||
do: :ok,
|
||||
else: {:error, main_module, expected_file}
|
||||
|
||||
true ->
|
||||
{:error, main_module, expected_file}
|
||||
end
|
||||
end
|
||||
|
||||
defp special_namespaces?(path), do: String.contains?(path, @special_namespaces)
|
||||
|
||||
defp parsed_path(relative_path, params) do
|
||||
parts = Path.split(relative_path)
|
||||
|
||||
allowed =
|
||||
Keyword.get(params, :ignore_folder_namespace, %{})
|
||||
|> Stream.flat_map(fn {root, folders} -> Enum.map(folders, &Path.join([root, &1])) end)
|
||||
|> Stream.map(&Path.split/1)
|
||||
|> Enum.find(&List.starts_with?(parts, &1))
|
||||
|> case do
|
||||
nil ->
|
||||
relative_path
|
||||
|
||||
ignore_parts ->
|
||||
Stream.drop(ignore_parts, -1)
|
||||
|> Enum.concat(Stream.drop(parts, length(ignore_parts)))
|
||||
|> Path.join()
|
||||
end
|
||||
|
||||
%{root: hd(parts), allowed: allowed}
|
||||
end
|
||||
|
||||
defp expected_file_base(root_folder, module) do
|
||||
{parent_namespace, module_name} = module |> Module.split() |> Enum.split(-1)
|
||||
|
||||
relative_path =
|
||||
if parent_namespace == [],
|
||||
do: "",
|
||||
else: parent_namespace |> Module.concat() |> Macro.underscore()
|
||||
|
||||
file_name = module_name |> Module.concat() |> Macro.underscore()
|
||||
|
||||
Path.join([root_folder, relative_path, file_name])
|
||||
end
|
||||
|
||||
defp error(issue_meta, module, expected_file) do
|
||||
format_issue(issue_meta,
|
||||
message:
|
||||
"Mismatch between file name and main module #{inspect(module)}. " <>
|
||||
"Expected file path to be #{expected_file}. " <>
|
||||
"Either move the file or rename the module.",
|
||||
line_no: 1
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
defmodule Mix.Tasks.Pleroma.InstanceTest do
|
||||
use ExUnit.Case
|
||||
|
||||
@release_env_file "./test/pleroma.test.env"
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(tmp_path())
|
||||
|
||||
|
|
@ -16,6 +18,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
|
|||
File.rm_rf(Path.join(static_dir, "robots.txt"))
|
||||
end
|
||||
|
||||
if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file)
|
||||
|
||||
Pleroma.Config.put([:instance, :static_dir], static_dir)
|
||||
end)
|
||||
|
||||
|
|
@ -69,7 +73,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
|
|||
"--dedupe-uploads",
|
||||
"n",
|
||||
"--anonymize-uploads",
|
||||
"n"
|
||||
"n",
|
||||
"--release-env-file",
|
||||
@release_env_file
|
||||
])
|
||||
end
|
||||
|
||||
|
|
@ -91,6 +97,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
|
|||
assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
|
||||
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
|
||||
assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
|
||||
assert File.exists?(@release_env_file)
|
||||
|
||||
assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/
|
||||
end
|
||||
|
||||
defp generated_setup_psql do
|
||||
|
|
|
|||
30
test/mix/tasks/pleroma/release_env_test.exs
Normal file
30
test/mix/tasks/pleroma/release_env_test.exs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.ReleaseEnvTest do
|
||||
use ExUnit.Case
|
||||
import ExUnit.CaptureIO, only: [capture_io: 1]
|
||||
|
||||
@path "config/pleroma.test.env"
|
||||
|
||||
def do_clean do
|
||||
if File.exists?(@path) do
|
||||
File.rm_rf(@path)
|
||||
end
|
||||
end
|
||||
|
||||
setup do
|
||||
do_clean()
|
||||
on_exit(fn -> do_clean() end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "generate pleroma.env" do
|
||||
assert capture_io(fn ->
|
||||
Mix.Tasks.Pleroma.ReleaseEnv.run(["gen", "--path", @path, "--force"])
|
||||
end) =~ "The file generated"
|
||||
|
||||
assert File.read!(@path) =~ "RELEASE_COOKIE="
|
||||
end
|
||||
end
|
||||
|
|
@ -248,14 +248,19 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.is_moderator
|
||||
assert user.locked
|
||||
assert user.is_locked
|
||||
assert user.is_admin
|
||||
refute user.confirmation_pending
|
||||
end
|
||||
|
||||
test "All statuses unset" do
|
||||
user =
|
||||
insert(:user, locked: true, is_moderator: true, is_admin: true, confirmation_pending: true)
|
||||
insert(:user,
|
||||
is_locked: true,
|
||||
is_moderator: true,
|
||||
is_admin: true,
|
||||
confirmation_pending: true
|
||||
)
|
||||
|
||||
Mix.Tasks.Pleroma.User.run([
|
||||
"set",
|
||||
|
|
@ -280,7 +285,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
refute user.is_moderator
|
||||
refute user.locked
|
||||
refute user.is_locked
|
||||
refute user.is_admin
|
||||
assert user.confirmation_pending
|
||||
end
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ defmodule Pleroma.NotificationTest do
|
|||
describe "follow / follow_request notifications" do
|
||||
test "it creates `follow` notification for approved Follow activity" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, locked: false)
|
||||
followed_user = insert(:user, is_locked: false)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
assert FollowingRelationship.following?(user, followed_user)
|
||||
|
|
@ -361,7 +361,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
test "it creates `follow_request` notification for pending Follow activity" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, locked: true)
|
||||
followed_user = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
refute FollowingRelationship.following?(user, followed_user)
|
||||
|
|
@ -383,7 +383,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
test "it doesn't create a notification for follow-unfollow-follow chains" do
|
||||
user = insert(:user)
|
||||
followed_user = insert(:user, locked: false)
|
||||
followed_user = insert(:user, is_locked: false)
|
||||
|
||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||
assert FollowingRelationship.following?(user, followed_user)
|
||||
|
|
@ -397,7 +397,7 @@ defmodule Pleroma.NotificationTest do
|
|||
end
|
||||
|
||||
test "dismisses the notification on follow request rejection" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
|
||||
assert [notification] = Notification.for_user(user)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], false)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ defmodule Pleroma.ObjectTest do
|
|||
File.mkdir_p!(uploads_dir)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ defmodule Pleroma.ObjectTest do
|
|||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do
|
|||
|
||||
upload_file = %Upload{
|
||||
name: "an… image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.Upload.Filter.DedupeTest do
|
|||
|
||||
upload = %Upload{
|
||||
name: "an… image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Upload.Filter.ExiftoolTest do
|
|||
|
||||
upload = %Pleroma.Upload{
|
||||
name: "image_with_GPS_data.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/DSCN0010.jpg"),
|
||||
tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ defmodule Pleroma.Upload.Filter.MogrifunTest do
|
|||
|
||||
upload = %Upload{
|
||||
name: "an… image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.Upload.Filter.MogrifyTest do
|
|||
|
||||
upload = %Pleroma.Upload{
|
||||
name: "an… image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ defmodule Pleroma.Upload.FilterTest do
|
|||
|
||||
upload = %Pleroma.Upload{
|
||||
name: "an… image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.UploadTest do
|
|||
alias Pleroma.Uploaders.Uploader
|
||||
|
||||
@upload_file %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "image.jpg"
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "image.jpg"
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "image.jpg"
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an [image.jpg"
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an [image.jpg"
|
||||
}
|
||||
|
|
@ -165,63 +165,31 @@ defmodule Pleroma.UploadTest do
|
|||
assert data["name"] == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "fixes incorrect content type" do
|
||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "application/octet-stream",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an [image.jpg"
|
||||
test "fixes incorrect content type when base64 is given" do
|
||||
params = %{
|
||||
img: "data:image/png;base64,#{Base.encode64(File.read!("test/fixtures/image.jpg"))}"
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file, filters: [Pleroma.Upload.Filter.Dedupe])
|
||||
{:ok, data} = Upload.store(params)
|
||||
assert hd(data["url"])["mediaType"] == "image/jpeg"
|
||||
end
|
||||
|
||||
test "adds missing extension" do
|
||||
test "adds extension when base64 is given" do
|
||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an [image"
|
||||
params = %{
|
||||
img: "data:image/png;base64,#{Base.encode64(File.read!("test/fixtures/image.jpg"))}"
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "fixes incorrect file extension" do
|
||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an [image.blah"
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "an [image.jpg"
|
||||
end
|
||||
|
||||
test "don't modify filename of an unknown type" do
|
||||
File.cp("test/fixtures/test.txt", "test/fixtures/test_tmp.txt")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "text/plain",
|
||||
path: Path.absname("test/fixtures/test_tmp.txt"),
|
||||
filename: "test.txt"
|
||||
}
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
assert data["name"] == "test.txt"
|
||||
{:ok, data} = Upload.store(params)
|
||||
assert String.ends_with?(data["name"], ".jpg")
|
||||
end
|
||||
|
||||
test "copies the file to the configured folder with anonymizing filename" do
|
||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an [image.jpg"
|
||||
}
|
||||
|
|
@ -235,7 +203,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "an… image.jpg"
|
||||
}
|
||||
|
|
@ -250,7 +218,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: ":?#[]@!$&\\'()*+,;=.jpg"
|
||||
}
|
||||
|
|
@ -272,7 +240,7 @@ defmodule Pleroma.UploadTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Uploaders.LocalTest do
|
|||
|
||||
file = %Pleroma.Upload{
|
||||
name: "image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: file_path,
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Uploaders.LocalTest do
|
|||
|
||||
file = %Pleroma.Upload{
|
||||
name: "image.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: file_path,
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ defmodule Pleroma.Uploaders.S3Test do
|
|||
setup do
|
||||
file_upload = %Pleroma.Upload{
|
||||
name: "image-tet.jpg",
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: "test_folder/image-tet.jpg",
|
||||
tempfile: Path.absname("test/instance_static/add/shortcode.png")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ defmodule Pleroma.UserSearchTest do
|
|||
end
|
||||
|
||||
test "excludes users when discoverable is false" do
|
||||
insert(:user, %{nickname: "john 3000", discoverable: false})
|
||||
insert(:user, %{nickname: "john 3000", is_discoverable: false})
|
||||
insert(:user, %{nickname: "john 3001"})
|
||||
|
||||
users = User.search("john")
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
test "returns all pending follow requests" do
|
||||
unlocked = insert(:user)
|
||||
locked = insert(:user, locked: true)
|
||||
locked = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
CommonAPI.follow(follower, unlocked)
|
||||
|
|
@ -187,7 +187,7 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
test "doesn't return already accepted or duplicate follow requests" do
|
||||
locked = insert(:user, locked: true)
|
||||
locked = insert(:user, is_locked: true)
|
||||
pending_follower = insert(:user)
|
||||
accepted_follower = insert(:user)
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
test "doesn't return follow requests for deactivated accounts" do
|
||||
locked = insert(:user, locked: true)
|
||||
locked = insert(:user, is_locked: true)
|
||||
pending_follower = insert(:user, %{deactivated: true})
|
||||
|
||||
CommonAPI.follow(pending_follower, locked)
|
||||
|
|
@ -211,7 +211,7 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
test "clears follow requests when requester is blocked" do
|
||||
followed = insert(:user, locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
|
@ -299,8 +299,8 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
|
||||
test "local users do not automatically follow local locked accounts" do
|
||||
follower = insert(:user, locked: true)
|
||||
followed = insert(:user, locked: true)
|
||||
follower = insert(:user, is_locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, follower} = User.maybe_direct_follow(follower, followed)
|
||||
|
||||
|
|
@ -1360,7 +1360,7 @@ defmodule Pleroma.UserTest do
|
|||
follower = insert(:user)
|
||||
{:ok, follower} = User.follow(follower, user)
|
||||
|
||||
locked_user = insert(:user, name: "locked", locked: true)
|
||||
locked_user = insert(:user, name: "locked", is_locked: true)
|
||||
{:ok, _} = User.follow(user, locked_user, :follow_pending)
|
||||
|
||||
object = insert(:note, user: user)
|
||||
|
|
@ -1450,7 +1450,7 @@ defmodule Pleroma.UserTest do
|
|||
note_count: 9,
|
||||
follower_count: 9,
|
||||
following_count: 9001,
|
||||
locked: true,
|
||||
is_locked: true,
|
||||
confirmation_pending: true,
|
||||
password_reset_pending: true,
|
||||
approval_pending: true,
|
||||
|
|
@ -1467,7 +1467,7 @@ defmodule Pleroma.UserTest do
|
|||
pleroma_settings_store: %{"q" => "x"},
|
||||
fields: [%{"gg" => "qq"}],
|
||||
raw_fields: [%{"gg" => "qq"}],
|
||||
discoverable: true,
|
||||
is_discoverable: true,
|
||||
also_known_as: ["https://lol.olo/users/loll"]
|
||||
})
|
||||
|
||||
|
|
@ -1492,7 +1492,7 @@ defmodule Pleroma.UserTest do
|
|||
note_count: 0,
|
||||
follower_count: 0,
|
||||
following_count: 0,
|
||||
locked: false,
|
||||
is_locked: false,
|
||||
confirmation_pending: false,
|
||||
password_reset_pending: false,
|
||||
approval_pending: false,
|
||||
|
|
@ -1509,7 +1509,7 @@ defmodule Pleroma.UserTest do
|
|||
pleroma_settings_store: %{},
|
||||
fields: [],
|
||||
raw_fields: [],
|
||||
discoverable: false,
|
||||
is_discoverable: false,
|
||||
also_known_as: []
|
||||
} = user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1487,9 +1487,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
desc = "Description of the image"
|
||||
|
||||
image = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "bad/content-type",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
filename: "an_image.png"
|
||||
}
|
||||
|
||||
object =
|
||||
|
|
@ -1504,6 +1504,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert [%{"href" => object_href, "mediaType" => object_mediatype}] = object["url"]
|
||||
assert is_binary(object_href)
|
||||
assert object_mediatype == "image/jpeg"
|
||||
assert String.ends_with?(object_href, ".jpg")
|
||||
|
||||
activity_request = %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
|
|
|
|||
|
|
@ -752,6 +752,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
refute repeat_activity in activities
|
||||
end
|
||||
|
||||
test "returns your own posts regardless of mute" do
|
||||
user = insert(:user)
|
||||
muted = insert(:user)
|
||||
|
||||
{:ok, muted_post} = CommonAPI.post(muted, %{status: "Im stupid"})
|
||||
|
||||
{:ok, reply} =
|
||||
CommonAPI.post(user, %{status: "I'm muting you", in_reply_to_status_id: muted_post.id})
|
||||
|
||||
{:ok, _} = User.mute(user, muted)
|
||||
|
||||
[activity] = ActivityPub.fetch_activities([], %{muting_user: user, skip_preload: true})
|
||||
|
||||
assert activity.id == reply.id
|
||||
end
|
||||
|
||||
test "doesn't return muted activities" do
|
||||
activity_one = insert(:note_activity)
|
||||
activity_two = insert(:note_activity)
|
||||
|
|
@ -1029,7 +1045,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
describe "uploading files" do
|
||||
setup do
|
||||
test_file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -1120,7 +1136,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
test "creates an undo activity for a pending follow request" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, %{locked: true})
|
||||
followed = insert(:user, %{is_locked: true})
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
{:ok, activity} = ActivityPub.unfollow(follower, followed)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidatorTest do
|
|||
user = insert(:user)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
|
|||
user: user
|
||||
} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
|
|||
user: user
|
||||
} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
|
|||
user: user
|
||||
} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
|
|||
|
||||
test "it works for incoming accepts which are referenced by IRI only" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
|
|||
|
||||
test "it fails for incoming accepts which cannot be correlated" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
|||
end
|
||||
|
||||
test "with locked accounts, it does create a Follow, but not an Accept" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|
|
@ -188,7 +188,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
|||
|
||||
test "it works for incoming follows to locked account" do
|
||||
pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
|
|||
|
||||
test "it fails for incoming rejects which cannot be correlated" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||
|
|
@ -33,7 +33,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
|
|||
|
||||
test "it works for incoming rejects which are referenced by IRI only" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, follower} = User.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
|
|
|
|||
|
|
@ -154,6 +154,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
|
|||
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data)
|
||||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
assert user.locked == true
|
||||
assert user.is_locked == true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
describe "update_follow_state_for_all/2" do
|
||||
test "updates the state of all Follow activities with the same actor and object" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
|
|
@ -217,7 +217,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
|
||||
describe "update_follow_state/2" do
|
||||
test "updates the state of the given follow activity" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ defmodule Pleroma.Web.AdminAPI.SearchTest do
|
|||
|
||||
test "it returns non-discoverable users" do
|
||||
insert(:user)
|
||||
insert(:user, discoverable: false)
|
||||
insert(:user, is_discoverable: false)
|
||||
|
||||
{:ok, _results, total} = Search.user()
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
recipient = insert(:user)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -1071,7 +1071,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
test "cancels a pending follow for a local user" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
followed = insert(:user, is_locked: true)
|
||||
|
||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
|
@ -1093,7 +1093,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
test "cancels a pending follow for a remote user" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true, local: false, ap_enabled: true)
|
||||
followed = insert(:user, is_locked: true, local: false, ap_enabled: true)
|
||||
|
||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
|
@ -1116,7 +1116,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
describe "accept_follow_request/2" do
|
||||
test "after acceptance, it sets all existing pending follow request states to 'accept'" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
follower_two = insert(:user)
|
||||
|
||||
|
|
@ -1136,7 +1136,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "after rejection, it sets all existing pending follow request states to 'reject'" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
follower = insert(:user)
|
||||
follower_two = insert(:user)
|
||||
|
||||
|
|
@ -1156,7 +1156,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
not_follower = insert(:user)
|
||||
CommonAPI.accept_follow_request(not_follower, user)
|
||||
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -706,7 +706,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
test "cancelling follow request", %{conn: conn} do
|
||||
%{id: other_user_id} = insert(:user, %{locked: true})
|
||||
%{id: other_user_id} = insert(:user, %{is_locked: true})
|
||||
|
||||
assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
|
||||
describe "locked accounts" do
|
||||
setup do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
%{conn: conn} = oauth_access(["follow"], user: user)
|
||||
%{user: user, conn: conn}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
|
||||
setup do
|
||||
image = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
|
||||
setup %{user: actor} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
|
||||
setup %{user: actor} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
test "posting an undefined status with an attachment", %{user: user, conn: conn} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -408,7 +408,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|> Kernel.<>("Z")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|
||||
test "updates the user's avatar", %{user: user, conn: conn} do
|
||||
new_avatar = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -246,7 +246,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|
||||
test "updates the user's banner", %{user: user, conn: conn} do
|
||||
new_header = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||
|
||||
test "updates the user's background", %{conn: conn, user: user} do
|
||||
new_header = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
|
||||
test "represent a relationship for the user with a pending follow request" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user, locked: true)
|
||||
other_user = insert(:user, is_locked: true)
|
||||
|
||||
{:ok, user, other_user, _} = CommonAPI.follow(user, other_user)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
|
@ -481,7 +481,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
end
|
||||
|
||||
test "shows non-zero when follow requests are pending" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
|
||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
end
|
||||
|
||||
test "decreases when accepting a follow request" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
|
||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
|
|
@ -510,7 +510,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
end
|
||||
|
||||
test "decreases when rejecting a follow request" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
|
||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
|
|
@ -527,14 +527,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
end
|
||||
|
||||
test "shows non-zero when historical unapproved requests are present" do
|
||||
user = insert(:user, locked: true)
|
||||
user = insert(:user, is_locked: true)
|
||||
|
||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||
|
||||
{:ok, user} = User.update_and_set_cache(user, %{locked: false})
|
||||
{:ok, user} = User.update_and_set_cache(user, %{is_locked: false})
|
||||
|
||||
assert %{locked: false, follow_requests_count: 1} =
|
||||
AccountView.render("show.json", %{user: user, for: user})
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
|
|||
|> NaiveDateTime.to_iso8601()
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexingTest do
|
|||
|
||||
test "for local user" do
|
||||
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||
user: %Pleroma.User{local: true, discoverable: true}
|
||||
user: %Pleroma.User{local: true, is_discoverable: true}
|
||||
}) == []
|
||||
end
|
||||
|
||||
test "for local user when discoverable is false" do
|
||||
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||
user: %Pleroma.User{local: true, discoverable: false}
|
||||
user: %Pleroma.User{local: true, is_discoverable: false}
|
||||
}) == [{:meta, [name: "robots", content: "noindex, noarchive"], []}]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ defmodule Pleroma.Web.MetadataTest do
|
|||
end
|
||||
|
||||
test "for local user" do
|
||||
user = insert(:user, discoverable: false)
|
||||
user = insert(:user, is_discoverable: false)
|
||||
|
||||
assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||
end
|
||||
|
||||
test "for local user set to discoverable" do
|
||||
user = insert(:user, discoverable: true)
|
||||
user = insert(:user, is_discoverable: true)
|
||||
|
||||
refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||
|
|
@ -33,14 +33,14 @@ defmodule Pleroma.Web.MetadataTest do
|
|||
describe "no metadata for private instances" do
|
||||
test "for local user set to discoverable" do
|
||||
clear_config([:instance, :public], false)
|
||||
user = insert(:user, bio: "This is my secret fedi account bio", discoverable: true)
|
||||
user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: true)
|
||||
|
||||
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
|
||||
end
|
||||
|
||||
test "search exclusion metadata is included" do
|
||||
clear_config([:instance, :public], false)
|
||||
user = insert(:user, bio: "This is my secret fedi account bio", discoverable: false)
|
||||
user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: false)
|
||||
|
||||
assert ~s(<meta content="noindex, noarchive" name="robots">) ==
|
||||
Pleroma.Web.Metadata.build_tags(%{user: user})
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
|
|||
|
||||
test "it works with an attachment", %{conn: conn, user: user} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
assert json_response_and_validate_schema(ret_conn, 415)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
|
||||
# When a user sets their mascot, we should get that back
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
|
|||
recipient = insert(:user)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Web.Plugs.UploadedMediaPlugTest do
|
|||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||
filename: "nice_tf.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ defmodule Pleroma.Web.Push.ImplTest do
|
|||
recipient = insert(:user)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ defmodule Pleroma.Factory do
|
|||
nickname: sequence(:nickname, &"nick#{&1}"),
|
||||
password_hash: Pbkdf2.hash_pwd_salt("test"),
|
||||
bio: sequence(:bio, &"Tester Number #{&1}"),
|
||||
discoverable: true,
|
||||
is_discoverable: true,
|
||||
last_digest_emailed_at: NaiveDateTime.utc_now(),
|
||||
last_refreshed_at: NaiveDateTime.utc_now(),
|
||||
notification_settings: %Pleroma.User.NotificationSetting{},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue