Merge branch 'issue/2089' into 'develop'
[#2089] fix notifications See merge request pleroma/pleroma!3000
This commit is contained in:
commit
6b088ed76a
13 changed files with 125 additions and 56 deletions
|
|
@ -33,8 +33,8 @@ defmodule Pleroma.MarkerTest do
|
|||
test "returns user markers" do
|
||||
user = insert(:user)
|
||||
marker = insert(:marker, user: user)
|
||||
insert(:notification, user: user)
|
||||
insert(:notification, user: user)
|
||||
insert(:notification, user: user, activity: insert(:note_activity))
|
||||
insert(:notification, user: user, activity: insert(:note_activity))
|
||||
insert(:marker, timeline: "home", user: user)
|
||||
|
||||
assert Marker.get_markers(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ defmodule Pleroma.RepoTest do
|
|||
|
||||
test "get one-to-many assoc from repo" do
|
||||
user = insert(:user)
|
||||
notification = refresh_record(insert(:notification, user: user))
|
||||
|
||||
notification =
|
||||
refresh_record(insert(:notification, user: user, activity: insert(:note_activity)))
|
||||
|
||||
assert Repo.get_assoc(user, :notifications) == {:ok, [notification]}
|
||||
end
|
||||
|
|
@ -47,4 +49,32 @@ defmodule Pleroma.RepoTest do
|
|||
assert Repo.get_assoc(token, :user) == {:error, :not_found}
|
||||
end
|
||||
end
|
||||
|
||||
describe "chunk_stream/3" do
|
||||
test "fetch records one-by-one" do
|
||||
users = insert_list(50, :user)
|
||||
|
||||
{fetch_users, 50} =
|
||||
from(t in User)
|
||||
|> Repo.chunk_stream(5)
|
||||
|> Enum.reduce({[], 0}, fn %User{} = user, {acc, count} ->
|
||||
{acc ++ [user], count + 1}
|
||||
end)
|
||||
|
||||
assert users == fetch_users
|
||||
end
|
||||
|
||||
test "fetch records in bulk" do
|
||||
users = insert_list(50, :user)
|
||||
|
||||
{fetch_users, 10} =
|
||||
from(t in User)
|
||||
|> Repo.chunk_stream(5, :batches)
|
||||
|> Enum.reduce({[], 0}, fn users, {acc, count} ->
|
||||
{acc ++ users, count + 1}
|
||||
end)
|
||||
|
||||
assert users == fetch_users
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1442,7 +1442,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
describe "verify_credentials" do
|
||||
test "verify_credentials" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:accounts"])
|
||||
[notification | _] = insert_list(7, :notification, user: user)
|
||||
|
||||
[notification | _] =
|
||||
insert_list(7, :notification, user: user, activity: insert(:note_activity))
|
||||
|
||||
Pleroma.Notification.set_read_up_to(user, notification.id)
|
||||
conn = get(conn, "/api/v1/accounts/verify_credentials")
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.MarkerControllerTest do
|
|||
test "gets markers with correct scopes", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
token = insert(:oauth_token, user: user, scopes: ["read:statuses"])
|
||||
insert_list(7, :notification, user: user)
|
||||
insert_list(7, :notification, user: user, activity: insert(:note_activity))
|
||||
|
||||
{:ok, %{"notifications" => marker}} =
|
||||
Pleroma.Marker.upsert(
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
|
||||
test "shows unread_count only to the account owner" do
|
||||
user = insert(:user)
|
||||
insert_list(7, :notification, user: user)
|
||||
insert_list(7, :notification, user: user, activity: insert(:note_activity))
|
||||
other_user = insert(:user)
|
||||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue