Rename fake param to preview and make the tests check that the object was not inserte...
authorrinpatch <rinpatch@sdf.org>
Tue, 2 Apr 2019 11:31:18 +0000 (14:31 +0300)
committerrinpatch <rinpatch@sdf.org>
Tue, 2 Apr 2019 11:31:18 +0000 (14:31 +0300)
docs/api/differences_in_mastoapi_responses.md
lib/pleroma/web/common_api/common_api.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index f5ce7493da3fac97ad2894992f935f74e1836416..7adf2967601f5fe0fe2f101905dd9e6279384e3d 100644 (file)
@@ -49,4 +49,4 @@ Has these additional fields under the `pleroma` object:
 
 Additional parameters can be added to the JSON body:
 
-- `fake`: boolean, if set to `true` the post won't be actually posted, but the status entitiy would still be rendered back. This could be useful for previewing rich text/custom emoji, for example.
+- `preview`: boolean, if set to `true` the post won't be actually posted, but the status entitiy would still be rendered back. This could be useful for previewing rich text/custom emoji, for example.
index 8e2937ac516a732f62f41d2036982968949f6170..2f82a32f3494b6b75f7ef1de62f82b7769488a14 100644 (file)
@@ -180,7 +180,7 @@ defmodule Pleroma.Web.CommonAPI do
             object: object,
             additional: %{"cc" => cc, "directMessage" => visibility == "direct"}
           },
-          data["fake"] || false
+          data["preview"] || false
         )
 
       res
index 3395c3689b5ad90daf5bb746bc693bb7001eba4f..d17d589627a64816a2154648cb225925eeb968be 100644 (file)
@@ -154,34 +154,41 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
           "\"Tenshi Eating a Corndog\" is a much discussed concept on /jp/. The significance of it is disputed, so I will focus on one core concept: the symbolism behind it"
       })
 
+    real_status = json_response(real_conn, 200)
+
+    assert real_status
+    assert Object.get_by_ap_id(real_status["uri"])
+
     real_status =
-      json_response(real_conn, 200)
+      real_status
       |> Map.put("id", nil)
       |> Map.put("url", nil)
       |> Map.put("uri", nil)
       |> Map.put("created_at", nil)
       |> Kernel.put_in(["pleroma", "conversation_id"], nil)
 
-    assert real_status
-
     fake_conn =
       conn
       |> assign(:user, user)
       |> post("/api/v1/statuses", %{
         "status" =>
           "\"Tenshi Eating a Corndog\" is a much discussed concept on /jp/. The significance of it is disputed, so I will focus on one core concept: the symbolism behind it",
-        "fake" => true
+        "preview" => true
       })
 
+    fake_status = json_response(fake_conn, 200)
+
+    assert fake_status
+    refute Object.get_by_ap_id(fake_status["uri"])
+
     fake_status =
-      json_response(fake_conn, 200)
+      fake_status
       |> Map.put("id", nil)
       |> Map.put("url", nil)
       |> Map.put("uri", nil)
       |> Map.put("created_at", nil)
       |> Kernel.put_in(["pleroma", "conversation_id"], nil)
 
-    assert fake_status
     assert real_status == fake_status
   end