Merge remote-tracking branch 'origin/develop' into reactions
This commit is contained in:
commit
b22ee9d966
238 changed files with 6405 additions and 6160 deletions
|
|
@ -6,7 +6,6 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -20,10 +19,10 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
setup do
|
||||
{:ok, user} =
|
||||
insert(:user)
|
||||
|> User.change_info(&User.Info.confirmation_changeset(&1, need_confirmation: true))
|
||||
|> Repo.update()
|
||||
|> User.confirmation_changeset(need_confirmation: true)
|
||||
|> User.update_and_set_cache()
|
||||
|
||||
assert user.info.confirmation_pending
|
||||
assert user.confirmation_pending
|
||||
|
||||
[user: user]
|
||||
end
|
||||
|
|
@ -105,7 +104,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|> patch("/api/v1/pleroma/accounts/update_banner", %{"banner" => @image})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.info.banner["type"] == "Image"
|
||||
assert user.banner["type"] == "Image"
|
||||
|
||||
assert %{"url" => _} = json_response(conn, 200)
|
||||
end
|
||||
|
|
@ -119,7 +118,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|> patch("/api/v1/pleroma/accounts/update_banner", %{"banner" => ""})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.info.banner == %{}
|
||||
assert user.banner == %{}
|
||||
|
||||
assert %{"url" => nil} = json_response(conn, 200)
|
||||
end
|
||||
|
|
@ -135,7 +134,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|> patch("/api/v1/pleroma/accounts/update_background", %{"img" => @image})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.info.background["type"] == "Image"
|
||||
assert user.background["type"] == "Image"
|
||||
assert %{"url" => _} = json_response(conn, 200)
|
||||
end
|
||||
|
||||
|
|
@ -148,14 +147,14 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|> patch("/api/v1/pleroma/accounts/update_background", %{"img" => ""})
|
||||
|
||||
user = refresh_record(user)
|
||||
assert user.info.background == %{}
|
||||
assert user.background == %{}
|
||||
assert %{"url" => nil} = json_response(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting favorites timeline of specified user" do
|
||||
setup do
|
||||
[current_user, user] = insert_pair(:user, %{info: %{hide_favorites: false}})
|
||||
[current_user, user] = insert_pair(:user, hide_favorites: false)
|
||||
[current_user: current_user, user: user]
|
||||
end
|
||||
|
||||
|
|
@ -319,7 +318,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
conn: conn,
|
||||
current_user: current_user
|
||||
} do
|
||||
user = insert(:user, %{info: %{hide_favorites: true}})
|
||||
user = insert(:user, hide_favorites: true)
|
||||
activity = insert(:note_activity)
|
||||
CommonAPI.favorite(activity.id, user)
|
||||
|
||||
|
|
@ -341,7 +340,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||
|> assign(:user, current_user)
|
||||
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
|
||||
|
||||
assert user.info.hide_favorites
|
||||
assert user.hide_favorites
|
||||
assert json_response(conn, 403) == %{"error" => "Can't get favorites"}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end
|
||||
|
||||
test "listing remote packs" do
|
||||
admin = insert(:user, info: %{is_admin: true})
|
||||
admin = insert(:user, is_admin: true)
|
||||
conn = build_conn() |> assign(:user, admin)
|
||||
|
||||
resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
|
||||
|
|
@ -121,7 +121,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
text(File.read!("#{@emoji_dir_path}/test_pack_nonshared/nonshared.zip"))
|
||||
end)
|
||||
|
||||
admin = insert(:user, info: %{is_admin: true})
|
||||
admin = insert(:user, is_admin: true)
|
||||
|
||||
conn = build_conn() |> assign(:user, admin)
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
{:ok,
|
||||
admin: insert(:user, info: %{is_admin: true}),
|
||||
admin: insert(:user, is_admin: true),
|
||||
pack_file: pack_file,
|
||||
new_data: %{
|
||||
"license" => "Test license changed",
|
||||
|
|
@ -303,7 +303,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
File.rm_rf!("#{@emoji_dir_path}/test_pack/dir_2")
|
||||
end)
|
||||
|
||||
admin = insert(:user, info: %{is_admin: true})
|
||||
admin = insert(:user, is_admin: true)
|
||||
|
||||
conn = build_conn()
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
File.rm_rf!("#{@emoji_dir_path}/test_created")
|
||||
end)
|
||||
|
||||
admin = insert(:user, info: %{is_admin: true})
|
||||
admin = insert(:user, is_admin: true)
|
||||
|
||||
conn = build_conn() |> assign(:user, admin)
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
refute Map.has_key?(resp, "test_pack_for_import")
|
||||
|
||||
admin = insert(:user, info: %{is_admin: true})
|
||||
admin = insert(:user, is_admin: true)
|
||||
|
||||
assert conn
|
||||
|> assign(:user, admin)
|
||||
|
|
|
|||
|
|
@ -155,6 +155,33 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
assert other_user in participation.recipients
|
||||
end
|
||||
|
||||
test "POST /api/v1/pleroma/conversations/read", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
|
||||
|
||||
[participation2, participation1] = Participation.for_user(other_user)
|
||||
assert Participation.get(participation2.id).read == false
|
||||
assert Participation.get(participation1.id).read == false
|
||||
assert User.get_cached_by_id(other_user.id).unread_conversation_count == 2
|
||||
|
||||
[%{"unread" => false}, %{"unread" => false}] =
|
||||
conn
|
||||
|> assign(:user, other_user)
|
||||
|> post("/api/v1/pleroma/conversations/read", %{})
|
||||
|> json_response(200)
|
||||
|
||||
[participation2, participation1] = Participation.for_user(other_user)
|
||||
assert Participation.get(participation2.id).read == true
|
||||
assert Participation.get(participation1.id).read == true
|
||||
assert User.get_cached_by_id(other_user.id).unread_conversation_count == 0
|
||||
end
|
||||
|
||||
describe "POST /api/v1/pleroma/notifications/read" do
|
||||
test "it marks a single notification as read", %{conn: conn} do
|
||||
user1 = insert(:user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue