diff options
| author | lain <lain@soykaf.club> | 2020-05-08 09:23:01 +0000 |
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-05-08 09:23:01 +0000 |
| commit | 0cf43391f272b2bb756b564e12bbcd3efda6a4bd (patch) | |
| tree | 3ce1732a3a997de5070e005f9b4102a5c01c878c /test/web/mastodon_api/views | |
| parent | 218a22c9a36ff2f8de353110f0badfc1ec5aa0f2 (diff) | |
| parent | a081135365c2b9d7bc81ee84baffbc3c2be68e8c (diff) | |
| download | pleroma-0cf43391f272b2bb756b564e12bbcd3efda6a4bd.tar.gz pleroma-0cf43391f272b2bb756b564e12bbcd3efda6a4bd.zip | |
Merge branch 'issue/1276-2' into 'develop'
[#1276] added an endpoint for getting unread notification count
See merge request pleroma/pleroma!2392
Diffstat (limited to 'test/web/mastodon_api/views')
| -rw-r--r-- | test/web/mastodon_api/views/account_view_test.exs | 18 | ||||
| -rw-r--r-- | test/web/mastodon_api/views/marker_view_test.exs | 8 |
2 files changed, 23 insertions, 3 deletions
diff --git a/test/web/mastodon_api/views/account_view_test.exs b/test/web/mastodon_api/views/account_view_test.exs index 85fa4f6a2..5fb162141 100644 --- a/test/web/mastodon_api/views/account_view_test.exs +++ b/test/web/mastodon_api/views/account_view_test.exs @@ -466,6 +466,24 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do :unread_conversation_count ] == 1 end + + test "shows unread_count only to the account owner" do + user = insert(:user) + insert_list(7, :notification, user: user) + other_user = insert(:user) + + user = User.get_cached_by_ap_id(user.ap_id) + + assert AccountView.render( + "show.json", + %{user: user, for: other_user} + )[:pleroma][:unread_notifications_count] == nil + + assert AccountView.render( + "show.json", + %{user: user, for: user} + )[:pleroma][:unread_notifications_count] == 7 + end end describe "follow requests counter" do diff --git a/test/web/mastodon_api/views/marker_view_test.exs b/test/web/mastodon_api/views/marker_view_test.exs index 893cf8857..48a0a6d33 100644 --- a/test/web/mastodon_api/views/marker_view_test.exs +++ b/test/web/mastodon_api/views/marker_view_test.exs @@ -8,19 +8,21 @@ defmodule Pleroma.Web.MastodonAPI.MarkerViewTest do import Pleroma.Factory test "returns markers" do - marker1 = insert(:marker, timeline: "notifications", last_read_id: "17") + marker1 = insert(:marker, timeline: "notifications", last_read_id: "17", unread_count: 5) marker2 = insert(:marker, timeline: "home", last_read_id: "42") assert MarkerView.render("markers.json", %{markers: [marker1, marker2]}) == %{ "home" => %{ last_read_id: "42", updated_at: NaiveDateTime.to_iso8601(marker2.updated_at), - version: 0 + version: 0, + pleroma: %{unread_count: 0} }, "notifications" => %{ last_read_id: "17", updated_at: NaiveDateTime.to_iso8601(marker1.updated_at), - version: 0 + version: 0, + pleroma: %{unread_count: 5} } } end |
