Merge branch 'develop' into feature/activitypub
[akkoma] / test / web / twitter_api / views / user_view_test.exs
index 3f84e4116959e76c54b9b3f373783917561b2a58..9e0a8a532e8dbcc051006db019df76b704fb8763 100644 (file)
@@ -33,8 +33,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
     {:ok, user} = User.update_follower_count(user)
     Cachex.set(:user_cache, "user_info:#{user.id}", User.user_info(Repo.get!(User, user.id)))
 
-    image = "http://localhost:4001/static/avi.png"
-    banner = "http://localhost:4001/static/banner.png"
+    image = "http://localhost:4001/images/avi.png"
+    banner = "http://localhost:4001/images/banner.png"
 
     represented = %{
       "id" => user.id,
@@ -53,10 +53,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => false,
       "follows_you" => false,
       "statusnet_blocking" => false,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => user.ap_id,
       "cover_photo" => banner,
-      "background_image" => nil
+      "background_image" => nil,
+      "is_local" => true
     }
 
     assert represented == UserView.render("show.json", %{user: user})
@@ -65,8 +68,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
   test "A user for a given other follower", %{user: user} do
     {:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
     {:ok, user} = User.update_follower_count(user)
-    image = "http://localhost:4001/static/avi.png"
-    banner = "http://localhost:4001/static/banner.png"
+    image = "http://localhost:4001/images/avi.png"
+    banner = "http://localhost:4001/images/banner.png"
 
     represented = %{
       "id" => user.id,
@@ -85,10 +88,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => true,
       "follows_you" => false,
       "statusnet_blocking" => false,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => user.ap_id,
       "cover_photo" => banner,
-      "background_image" => nil
+      "background_image" => nil,
+      "is_local" => true
     }
 
     assert represented == UserView.render("show.json", %{user: user, for: follower})
@@ -98,8 +104,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
     follower = insert(:user)
     {:ok, follower} = User.follow(follower, user)
     {:ok, user} = User.update_follower_count(user)
-    image = "http://localhost:4001/static/avi.png"
-    banner = "http://localhost:4001/static/banner.png"
+    image = "http://localhost:4001/images/avi.png"
+    banner = "http://localhost:4001/images/banner.png"
 
     represented = %{
       "id" => follower.id,
@@ -118,21 +124,31 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => false,
       "follows_you" => true,
       "statusnet_blocking" => false,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => follower.ap_id,
       "cover_photo" => banner,
-      "background_image" => nil
+      "background_image" => nil,
+      "is_local" => true
     }
 
     assert represented == UserView.render("show.json", %{user: follower, for: user})
   end
 
-  test "A blocked user for the blocker", %{user: user} do
+  test "a user that is a moderator" do
+    user = insert(:user, %{info: %{"is_moderator" => true}})
+    represented = UserView.render("show.json", %{user: user, for: user})
+
+    assert represented["rights"]["delete_others_notice"]
+  end
+
+  test "A blocked user for the blocker" do
     user = insert(:user)
     blocker = insert(:user)
     User.block(blocker, user)
-    image = "http://localhost:4001/static/avi.png"
-    banner = "http://localhost:4001/static/banner.png"
+    image = "http://localhost:4001/images/avi.png"
+    banner = "http://localhost:4001/images/banner.png"
 
     represented = %{
       "id" => user.id,
@@ -151,10 +167,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => false,
       "follows_you" => false,
       "statusnet_blocking" => true,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => user.ap_id,
       "cover_photo" => banner,
-      "background_image" => nil
+      "background_image" => nil,
+      "is_local" => true
     }
 
     blocker = Repo.get(User, blocker.id)