Bump Copyright to 2021
[akkoma] / test / pleroma / web / mastodon_api / views / account_view_test.exs
index 90b436376063ca178c4c02a0238e60bb03186486..32fe081968f317e9d81f2d6b66116e3a8ed60dde 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
@@ -35,7 +35,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
           "<script src=\"invalid-html\"></script><span>valid html</span>. a<br>b<br/>c<br >d<br />f '&<>\"",
         inserted_at: ~N[2017-08-15 15:47:06.597036],
         emoji: %{"karjalanpiirakka" => "/file.png"},
-        raw_bio: "valid html. a\nb\nc\nd\nf '&<>\""
+        raw_bio: "valid html. a\nb\nc\nd\nf '&<>\"",
+        also_known_as: ["https://shitposter.zone/users/shp"]
       })
 
     expected = %{
@@ -43,7 +44,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       username: "shp",
       acct: user.nickname,
       display_name: user.name,
-      is_locked: false,
+      locked: false,
       created_at: "2017-08-15T15:47:06.000Z",
       followers_count: 3,
       following_count: 0,
@@ -75,6 +76,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       },
       pleroma: %{
         ap_id: user.ap_id,
+        also_known_as: ["https://shitposter.zone/users/shp"],
         background_image: "https://example.com/images/asuka_hospital.png",
         favicon: nil,
         confirmation_pending: false,
@@ -148,7 +150,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       username: "shp",
       acct: user.nickname,
       display_name: user.name,
-      is_locked: false,
+      locked: false,
       created_at: "2017-08-15T15:47:06.000Z",
       followers_count: 3,
       following_count: 0,
@@ -173,6 +175,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       },
       pleroma: %{
         ap_id: user.ap_id,
+        also_known_as: [],
         background_image: nil,
         favicon: nil,
         confirmation_pending: false,
@@ -274,10 +277,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       user = insert(:user)
       other_user = insert(:user)
 
-      {:ok, user} = User.follow(user, other_user)
-      {:ok, other_user} = User.follow(other_user, user)
+      {:ok, user, other_user} = User.follow(user, other_user)
+      {:ok, other_user, user} = User.follow(other_user, user)
       {:ok, _subscription} = User.subscribe(user, other_user)
-      {:ok, _user_relationships} = User.mute(user, other_user, true)
+      {:ok, _user_relationships} = User.mute(user, other_user, %{notifications: true})
       {:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, other_user)
 
       expected =
@@ -301,7 +304,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
       user = insert(:user)
       other_user = insert(:user)
 
-      {:ok, user} = User.follow(user, other_user)
+      {:ok, user, other_user} = User.follow(user, other_user)
       {:ok, _subscription} = User.subscribe(user, other_user)
       {:ok, _user_relationship} = User.block(user, other_user)
       {:ok, _user_relationship} = User.block(other_user, user)
@@ -483,60 +486,60 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
     test "shows non-zero when follow requests are pending" do
       user = insert(:user, is_locked: true)
 
-      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      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)
 
-      assert %{is_locked: true, follow_requests_count: 1} =
+      assert %{locked: true, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
     end
 
     test "decreases when accepting a follow request" do
       user = insert(:user, is_locked: true)
 
-      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      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)
 
-      assert %{is_locked: true, follow_requests_count: 1} =
+      assert %{locked: true, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
 
       {:ok, _other_user} = CommonAPI.accept_follow_request(other_user, user)
 
-      assert %{is_locked: true, follow_requests_count: 0} =
+      assert %{locked: true, follow_requests_count: 0} =
                AccountView.render("show.json", %{user: user, for: user})
     end
 
     test "decreases when rejecting a follow request" do
       user = insert(:user, is_locked: true)
 
-      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      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)
 
-      assert %{is_locked: true, follow_requests_count: 1} =
+      assert %{locked: true, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
 
       {:ok, _other_user} = CommonAPI.reject_follow_request(other_user, user)
 
-      assert %{is_locked: true, follow_requests_count: 0} =
+      assert %{locked: true, follow_requests_count: 0} =
                AccountView.render("show.json", %{user: user, for: user})
     end
 
     test "shows non-zero when historical unapproved requests are present" do
       user = insert(:user, is_locked: true)
 
-      assert %{is_locked: true} = AccountView.render("show.json", %{user: user, for: user})
+      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, %{is_locked: false})
 
-      assert %{is_locked: false, follow_requests_count: 1} =
+      assert %{locked: false, follow_requests_count: 1} =
                AccountView.render("show.json", %{user: user, for: user})
     end
   end