Fix if clause in activity_pub user_view
[akkoma] / test / web / twitter_api / util_controller_test.exs
1 defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
2 use Pleroma.Web.ConnCase
3
4 import Pleroma.Factory
5
6 describe "POST /api/pleroma/follow_import" do
7 test "it returns HTTP 200", %{conn: conn} do
8 user1 = insert(:user)
9 user2 = insert(:user)
10
11 response =
12 conn
13 |> assign(:user, user1)
14 |> post("/api/pleroma/follow_import", %{"list" => "#{user2.ap_id}"})
15 |> json_response(:ok)
16
17 assert response == "job started"
18 end
19 end
20
21 describe "POST /api/pleroma/blocks_import" do
22 test "it returns HTTP 200", %{conn: conn} do
23 user1 = insert(:user)
24 user2 = insert(:user)
25
26 response =
27 conn
28 |> assign(:user, user1)
29 |> post("/api/pleroma/blocks_import", %{"list" => "#{user2.ap_id}"})
30 |> json_response(:ok)
31
32 assert response == "job started"
33 end
34 end
35
36 describe "GET /api/statusnet/config.json" do
37 test "it returns the managed config", %{conn: conn} do
38 Pleroma.Config.put([:instance, :managed_config], false)
39
40 response =
41 conn
42 |> get("/api/statusnet/config.json")
43 |> json_response(:ok)
44
45 refute response["site"]["pleromafe"]
46
47 Pleroma.Config.put([:instance, :managed_config], true)
48
49 response =
50 conn
51 |> get("/api/statusnet/config.json")
52 |> json_response(:ok)
53
54 assert response["site"]["pleromafe"]
55 end
56
57 test "if :pleroma, :fe is false, it returns the new style config settings", %{conn: conn} do
58 Pleroma.Config.put([:instance, :managed_config], true)
59 Pleroma.Config.put([:fe, :theme], "rei-ayanami-towel")
60 Pleroma.Config.put([:frontend_configurations, :pleroma_fe], %{theme: "asuka-hospital"})
61
62 response =
63 conn
64 |> get("/api/statusnet/config.json")
65 |> json_response(:ok)
66
67 assert response["site"]["pleromafe"]["theme"] == "rei-ayanami-towel"
68
69 Pleroma.Config.put([:fe], false)
70
71 response =
72 conn
73 |> get("/api/statusnet/config.json")
74 |> json_response(:ok)
75
76 assert response["site"]["pleromafe"]["theme"] == "asuka-hospital"
77 end
78 end
79
80 describe "GET /api/pleroma/frontend_configurations" do
81 test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} do
82 config = [
83 frontend_a: %{
84 x: 1,
85 y: 2
86 },
87 frontend_b: %{
88 z: 3
89 }
90 ]
91
92 Pleroma.Config.put(:frontend_configurations, config)
93
94 response =
95 conn
96 |> get("/api/pleroma/frontend_configurations")
97 |> json_response(:ok)
98
99 assert response == Jason.encode!(config |> Enum.into(%{})) |> Jason.decode!()
100 end
101 end
102 end