aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/notification_test.exs12
-rw-r--r--test/object_test.exs3
-rw-r--r--test/tasks/database_test.exs2
-rw-r--r--test/user_test.exs4
-rw-r--r--test/web/activity_pub/object_validator_test.exs83
-rw-r--r--test/web/activity_pub/object_validators/note_validator_test.exs35
-rw-r--r--test/web/activity_pub/pipeline_test.exs87
-rw-r--r--test/web/activity_pub/side_effects_test.exs34
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs4
-rw-r--r--test/web/activity_pub/views/object_view_test.exs2
-rw-r--r--test/web/common_api/common_api_test.exs15
-rw-r--r--test/web/mastodon_api/controllers/notification_controller_test.exs2
-rw-r--r--test/web/mastodon_api/controllers/status_controller_test.exs29
-rw-r--r--test/web/mastodon_api/views/notification_view_test.exs2
-rw-r--r--test/web/ostatus/ostatus_controller_test.exs2
-rw-r--r--test/web/pleroma_api/controllers/account_controller_test.exs16
-rw-r--r--test/web/push/impl_test.exs2
-rw-r--r--test/web/streamer/streamer_test.exs6
18 files changed, 298 insertions, 42 deletions
diff --git a/test/notification_test.exs b/test/notification_test.exs
index dcbffeafe..2200d03ea 100644
--- a/test/notification_test.exs
+++ b/test/notification_test.exs
@@ -14,6 +14,8 @@ defmodule Pleroma.NotificationTest do
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Streamer
+ import ExUnit.CaptureLog
+
describe "create_notifications" do
test "notifies someone when they are directly addressed" do
user = insert(:user)
@@ -431,7 +433,7 @@ defmodule Pleroma.NotificationTest do
"status" => "hey @#{other_user.nickname}!"
})
- {:ok, activity_two, _} = CommonAPI.favorite(activity_one.id, third_user)
+ {:ok, activity_two} = CommonAPI.favorite(third_user, activity_one.id)
assert other_user not in Notification.get_notified_from_activity(activity_two)
end
@@ -461,7 +463,7 @@ defmodule Pleroma.NotificationTest do
assert Enum.empty?(Notification.for_user(user))
- {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+ {:ok, _} = CommonAPI.favorite(other_user, activity.id)
assert length(Notification.for_user(user)) == 1
@@ -478,7 +480,7 @@ defmodule Pleroma.NotificationTest do
assert Enum.empty?(Notification.for_user(user))
- {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+ {:ok, _} = CommonAPI.favorite(other_user, activity.id)
assert length(Notification.for_user(user)) == 1
@@ -533,7 +535,9 @@ defmodule Pleroma.NotificationTest do
assert Enum.empty?(Notification.for_user(user))
- {:error, _} = CommonAPI.favorite(activity.id, other_user)
+ assert capture_log(fn ->
+ {:error, _} = CommonAPI.favorite(other_user, activity.id)
+ end) =~ "[error]"
assert Enum.empty?(Notification.for_user(user))
end
diff --git a/test/object_test.exs b/test/object_test.exs
index 9247a6d84..643b50ae6 100644
--- a/test/object_test.exs
+++ b/test/object_test.exs
@@ -196,7 +196,8 @@ defmodule Pleroma.ObjectTest do
user = insert(:user)
activity = Activity.get_create_by_object_ap_id(object.data["id"])
- {:ok, _activity, object} = CommonAPI.favorite(activity.id, user)
+ {:ok, activity} = CommonAPI.favorite(user, activity.id)
+ object = Object.get_by_ap_id(activity.data["object"])
assert object.data["like_count"] == 1
diff --git a/test/tasks/database_test.exs b/test/tasks/database_test.exs
index 0c7883f33..77c102cce 100644
--- a/test/tasks/database_test.exs
+++ b/test/tasks/database_test.exs
@@ -102,7 +102,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
{:ok, %{id: id, object: object}} = CommonAPI.post(user, %{"status" => "test"})
{:ok, %{object: object2}} = CommonAPI.post(user, %{"status" => "test test"})
- CommonAPI.favorite(id, user2)
+ CommonAPI.favorite(user2, id)
likes = %{
"first" =>
diff --git a/test/user_test.exs b/test/user_test.exs
index c345e43e9..e1e57f07b 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -1039,8 +1039,8 @@ defmodule Pleroma.UserTest do
object_two = insert(:note, user: follower)
activity_two = insert(:note_activity, user: follower, note: object_two)
- {:ok, like, _} = CommonAPI.favorite(activity_two.id, user)
- {:ok, like_two, _} = CommonAPI.favorite(activity.id, follower)
+ {:ok, like} = CommonAPI.favorite(user, activity_two.id)
+ {:ok, like_two} = CommonAPI.favorite(follower, activity.id)
{:ok, repeat, _} = CommonAPI.repeat(activity_two.id, user)
{:ok, job} = User.delete(user)
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs
new file mode 100644
index 000000000..3c5c3696e
--- /dev/null
+++ b/test/web/activity_pub/object_validator_test.exs
@@ -0,0 +1,83 @@
+defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
+ use Pleroma.DataCase
+
+ alias Pleroma.Web.ActivityPub.ObjectValidator
+ alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
+ alias Pleroma.Web.ActivityPub.Utils
+ alias Pleroma.Web.CommonAPI
+
+ import Pleroma.Factory
+
+ describe "likes" do
+ setup do
+ user = insert(:user)
+ {:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
+
+ valid_like = %{
+ "to" => [user.ap_id],
+ "cc" => [],
+ "type" => "Like",
+ "id" => Utils.generate_activity_id(),
+ "object" => post_activity.data["object"],
+ "actor" => user.ap_id,
+ "context" => "a context"
+ }
+
+ %{valid_like: valid_like, user: user, post_activity: post_activity}
+ end
+
+ test "returns ok when called in the ObjectValidator", %{valid_like: valid_like} do
+ {:ok, object, _meta} = ObjectValidator.validate(valid_like, [])
+
+ assert "id" in Map.keys(object)
+ end
+
+ test "is valid for a valid object", %{valid_like: valid_like} do
+ assert LikeValidator.cast_and_validate(valid_like).valid?
+ end
+
+ test "it errors when the actor is missing or not known", %{valid_like: valid_like} do
+ without_actor = Map.delete(valid_like, "actor")
+
+ refute LikeValidator.cast_and_validate(without_actor).valid?
+
+ with_invalid_actor = Map.put(valid_like, "actor", "invalidactor")
+
+ refute LikeValidator.cast_and_validate(with_invalid_actor).valid?
+ end
+
+ test "it errors when the object is missing or not known", %{valid_like: valid_like} do
+ without_object = Map.delete(valid_like, "object")
+
+ refute LikeValidator.cast_and_validate(without_object).valid?
+
+ with_invalid_object = Map.put(valid_like, "object", "invalidobject")
+
+ refute LikeValidator.cast_and_validate(with_invalid_object).valid?
+ end
+
+ test "it errors when the actor has already like the object", %{
+ valid_like: valid_like,
+ user: user,
+ post_activity: post_activity
+ } do
+ _like = CommonAPI.favorite(user, post_activity.id)
+
+ refute LikeValidator.cast_and_validate(valid_like).valid?
+ end
+
+ test "it works when actor or object are wrapped in maps", %{valid_like: valid_like} do
+ wrapped_like =
+ valid_like
+ |> Map.put("actor", %{"id" => valid_like["actor"]})
+ |> Map.put("object", %{"id" => valid_like["object"]})
+
+ validated = LikeValidator.cast_and_validate(wrapped_like)
+
+ assert validated.valid?
+
+ assert {:actor, valid_like["actor"]} in validated.changes
+ assert {:object, valid_like["object"]} in validated.changes
+ end
+ end
+end
diff --git a/test/web/activity_pub/object_validators/note_validator_test.exs b/test/web/activity_pub/object_validators/note_validator_test.exs
new file mode 100644
index 000000000..2bcd75e25
--- /dev/null
+++ b/test/web/activity_pub/object_validators/note_validator_test.exs
@@ -0,0 +1,35 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidatorTest do
+ use Pleroma.DataCase
+
+ alias Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator
+ alias Pleroma.Web.ActivityPub.Utils
+
+ import Pleroma.Factory
+
+ describe "Notes" do
+ setup do
+ user = insert(:user)
+
+ note = %{
+ "id" => Utils.generate_activity_id(),
+ "type" => "Note",
+ "actor" => user.ap_id,
+ "to" => [user.follower_address],
+ "cc" => [],
+ "content" => "Hellow this is content.",
+ "context" => "xxx",
+ "summary" => "a post"
+ }
+
+ %{user: user, note: note}
+ end
+
+ test "a basic note validates", %{note: note} do
+ %{valid?: true} = NoteValidator.cast_and_validate(note)
+ end
+ end
+end
diff --git a/test/web/activity_pub/pipeline_test.exs b/test/web/activity_pub/pipeline_test.exs
new file mode 100644
index 000000000..318d306af
--- /dev/null
+++ b/test/web/activity_pub/pipeline_test.exs
@@ -0,0 +1,87 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.PipelineTest do
+ use Pleroma.DataCase
+
+ import Mock
+ import Pleroma.Factory
+
+ describe "common_pipeline/2" do
+ test "it goes through validation, filtering, persisting, side effects and federation for local activities" do
+ activity = insert(:note_activity)
+ meta = [local: true]
+
+ with_mocks([
+ {Pleroma.Web.ActivityPub.ObjectValidator, [], [validate: fn o, m -> {:ok, o, m} end]},
+ {
+ Pleroma.Web.ActivityPub.MRF,
+ [],
+ [filter: fn o -> {:ok, o} end]
+ },
+ {
+ Pleroma.Web.ActivityPub.ActivityPub,
+ [],
+ [persist: fn o, m -> {:ok, o, m} end]
+ },
+ {
+ Pleroma.Web.ActivityPub.SideEffects,
+ [],
+ [handle: fn o, m -> {:ok, o, m} end]
+ },
+ {
+ Pleroma.Web.Federator,
+ [],
+ [publish: fn _o -> :ok end]
+ }
+ ]) do
+ assert {:ok, ^activity, ^meta} =
+ Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
+
+ assert_called(Pleroma.Web.ActivityPub.ObjectValidator.validate(activity, meta))
+ assert_called(Pleroma.Web.ActivityPub.MRF.filter(activity))
+ assert_called(Pleroma.Web.ActivityPub.ActivityPub.persist(activity, meta))
+ assert_called(Pleroma.Web.ActivityPub.SideEffects.handle(activity, meta))
+ assert_called(Pleroma.Web.Federator.publish(activity))
+ end
+ end
+
+ test "it goes through validation, filtering, persisting, side effects without federation for remote activities" do
+ activity = insert(:note_activity)
+ meta = [local: false]
+
+ with_mocks([
+ {Pleroma.Web.ActivityPub.ObjectValidator, [], [validate: fn o, m -> {:ok, o, m} end]},
+ {
+ Pleroma.Web.ActivityPub.MRF,
+ [],
+ [filter: fn o -> {:ok, o} end]
+ },
+ {
+ Pleroma.Web.ActivityPub.ActivityPub,
+ [],
+ [persist: fn o, m -> {:ok, o, m} end]
+ },
+ {
+ Pleroma.Web.ActivityPub.SideEffects,
+ [],
+ [handle: fn o, m -> {:ok, o, m} end]
+ },
+ {
+ Pleroma.Web.Federator,
+ [],
+ []
+ }
+ ]) do
+ assert {:ok, ^activity, ^meta} =
+ Pleroma.Web.ActivityPub.Pipeline.common_pipeline(activity, meta)
+
+ assert_called(Pleroma.Web.ActivityPub.ObjectValidator.validate(activity, meta))
+ assert_called(Pleroma.Web.ActivityPub.MRF.filter(activity))
+ assert_called(Pleroma.Web.ActivityPub.ActivityPub.persist(activity, meta))
+ assert_called(Pleroma.Web.ActivityPub.SideEffects.handle(activity, meta))
+ end
+ end
+ end
+end
diff --git a/test/web/activity_pub/side_effects_test.exs b/test/web/activity_pub/side_effects_test.exs
new file mode 100644
index 000000000..ef91954ae
--- /dev/null
+++ b/test/web/activity_pub/side_effects_test.exs
@@ -0,0 +1,34 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
+ use Pleroma.DataCase
+
+ alias Pleroma.Object
+ alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Web.ActivityPub.Builder
+ alias Pleroma.Web.ActivityPub.SideEffects
+ alias Pleroma.Web.CommonAPI
+
+ import Pleroma.Factory
+
+ describe "like objects" do
+ setup do
+ user = insert(:user)
+ {:ok, post} = CommonAPI.post(user, %{"status" => "hey"})
+
+ {:ok, like_data, _meta} = Builder.like(user, post.object)
+ {:ok, like, _meta} = ActivityPub.persist(like_data, local: true)
+
+ %{like: like, user: user}
+ end
+
+ test "add the like to the original object", %{like: like, user: user} do
+ {:ok, like, _} = SideEffects.handle(like)
+ object = Object.get_by_ap_id(like.data["object"])
+ assert object.data["like_count"] == 1
+ assert user.ap_id in object.data["likes"]
+ end
+ end
+end
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 5da358c43..1910de6e0 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -332,7 +332,9 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|> Poison.decode!()
|> Map.put("object", activity.data["object"])
- {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+ {:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)
+
+ refute Enum.empty?(activity.recipients)
assert data["actor"] == "http://mastodon.example.org/users/admin"
assert data["type"] == "Like"
diff --git a/test/web/activity_pub/views/object_view_test.exs b/test/web/activity_pub/views/object_view_test.exs
index 13447dc29..998247c5c 100644
--- a/test/web/activity_pub/views/object_view_test.exs
+++ b/test/web/activity_pub/views/object_view_test.exs
@@ -41,7 +41,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
object = Object.normalize(note)
user = insert(:user)
- {:ok, like_activity, _} = CommonAPI.favorite(note.id, user)
+ {:ok, like_activity} = CommonAPI.favorite(user, note.id)
result = ObjectView.render("object.json", %{object: like_activity})
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 138488d44..d641f7478 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -14,6 +14,7 @@ defmodule Pleroma.Web.CommonAPITest do
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
+ import ExUnit.CaptureLog
require Pleroma.Constants
@@ -279,9 +280,12 @@ defmodule Pleroma.Web.CommonAPITest do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, post_activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
- {:ok, %Activity{}, _} = CommonAPI.favorite(activity.id, user)
+ {:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
+ assert data["type"] == "Like"
+ assert data["actor"] == user.ap_id
+ assert data["object"] == post_activity.data["object"]
end
test "retweeting a status twice returns an error" do
@@ -298,8 +302,11 @@ defmodule Pleroma.Web.CommonAPITest do
other_user = insert(:user)
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
- {:ok, %Activity{}, _object} = CommonAPI.favorite(activity.id, user)
- {:error, _} = CommonAPI.favorite(activity.id, user)
+ {:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
+
+ assert capture_log(fn ->
+ assert {:error, _} = CommonAPI.favorite(user, activity.id)
+ end) =~ "[error]"
end
end
diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs
index fa55a7cf9..c0b3621de 100644
--- a/test/web/mastodon_api/controllers/notification_controller_test.exs
+++ b/test/web/mastodon_api/controllers/notification_controller_test.exs
@@ -194,7 +194,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
{:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
- {:ok, favorite_activity, _} = CommonAPI.favorite(create_activity.id, other_user)
+ {:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
{:ok, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs
index a96fd860b..2ce201e2e 100644
--- a/test/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/web/mastodon_api/controllers/status_controller_test.exs
@@ -18,6 +18,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
+ import ExUnit.CaptureLog
clear_config([:instance, :federating])
clear_config([:instance, :allow_relay])
@@ -621,7 +622,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
user1 = insert(:user)
user2 = insert(:user)
user3 = insert(:user)
- CommonAPI.favorite(activity.id, user2)
+ {:ok, _} = CommonAPI.favorite(user2, activity.id)
{:ok, _bookmark} = Pleroma.Bookmark.create(user2.id, activity.id)
{:ok, reblog_activity1, _object} = CommonAPI.repeat(activity.id, user1)
{:ok, _, _object} = CommonAPI.repeat(activity.id, user2)
@@ -713,12 +714,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
test "returns 400 error for a wrong id", %{conn: conn} do
user = insert(:user)
- conn =
- conn
- |> assign(:user, user)
- |> post("/api/v1/statuses/1/favourite")
+ assert capture_log(fn ->
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/v1/statuses/1/favourite")
- assert json_response(conn, 400) == %{"error" => "Could not favorite"}
+ assert json_response(conn, 400) == %{"error" => "Could not favorite"}
+ end) =~ "[error]"
end
end
@@ -727,7 +730,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
activity = insert(:note_activity)
user = insert(:user)
- {:ok, _, _} = CommonAPI.favorite(activity.id, user)
+ {:ok, _} = CommonAPI.favorite(user, activity.id)
conn =
conn
@@ -1079,7 +1082,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
test "returns users who have favorited the status", %{conn: conn, activity: activity} do
other_user = insert(:user)
- {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+ {:ok, _} = CommonAPI.favorite(other_user, activity.id)
response =
conn
@@ -1110,7 +1113,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
other_user = insert(:user)
{:ok, user} = User.block(user, other_user)
- {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+ {:ok, _} = CommonAPI.favorite(other_user, activity.id)
response =
conn
@@ -1123,7 +1126,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
test "does not fail on an unauthenticated request", %{conn: conn, activity: activity} do
other_user = insert(:user)
- {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+ {:ok, _} = CommonAPI.favorite(other_user, activity.id)
response =
conn
@@ -1144,7 +1147,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
"visibility" => "direct"
})
- {:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
+ {:ok, _} = CommonAPI.favorite(other_user, activity.id)
conn
|> assign(:user, nil)
@@ -1301,7 +1304,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
{:ok, _} = CommonAPI.post(other_user, %{"status" => "bla"})
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "traps are happy"})
- {:ok, _, _} = CommonAPI.favorite(activity.id, user)
+ {:ok, _} = CommonAPI.favorite(user, activity.id)
first_conn =
conn
@@ -1321,7 +1324,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
"Trees Are Never Sad Look At Them Every Once In Awhile They're Quite Beautiful."
})
- {:ok, _, _} = CommonAPI.favorite(second_activity.id, user)
+ {:ok, _} = CommonAPI.favorite(user, second_activity.id)
last_like = status["id"]
diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs
index 26e1afc85..a741cc014 100644
--- a/test/web/mastodon_api/views/notification_view_test.exs
+++ b/test/web/mastodon_api/views/notification_view_test.exs
@@ -42,7 +42,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
user = insert(:user)
another_user = insert(:user)
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
- {:ok, favorite_activity, _object} = CommonAPI.favorite(create_activity.id, another_user)
+ {:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id)
{:ok, [notification]} = Notification.create_notifications(favorite_activity)
create_activity = Activity.get_by_id(create_activity.id)
diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs
index 50235dfef..567aabbf1 100644
--- a/test/web/ostatus/ostatus_controller_test.exs
+++ b/test/web/ostatus/ostatus_controller_test.exs
@@ -146,7 +146,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
user = insert(:user)
- {:ok, like_activity, _} = CommonAPI.favorite(note_activity.id, user)
+ {:ok, like_activity} = CommonAPI.favorite(user, note_activity.id)
assert like_activity.data["type"] == "Like"
diff --git a/test/web/pleroma_api/controllers/account_controller_test.exs b/test/web/pleroma_api/controllers/account_controller_test.exs
index c809f510f..c9f67c280 100644
--- a/test/web/pleroma_api/controllers/account_controller_test.exs
+++ b/test/web/pleroma_api/controllers/account_controller_test.exs
@@ -164,7 +164,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
user: user
} do
[activity | _] = insert_pair(:note_activity)
- CommonAPI.favorite(activity.id, user)
+ CommonAPI.favorite(user, activity.id)
response =
conn
@@ -183,7 +183,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
user: user
} do
activity = insert(:note_activity)
- CommonAPI.favorite(activity.id, user)
+ CommonAPI.favorite(user, activity.id)
response =
conn
@@ -204,7 +204,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
"visibility" => "direct"
})
- CommonAPI.favorite(direct.id, user)
+ CommonAPI.favorite(user, direct.id)
response =
conn
@@ -235,7 +235,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
"visibility" => "direct"
})
- CommonAPI.favorite(direct.id, user)
+ CommonAPI.favorite(user, direct.id)
response =
conn
@@ -254,7 +254,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
activities = insert_list(10, :note_activity)
Enum.each(activities, fn activity ->
- CommonAPI.favorite(activity.id, user)
+ CommonAPI.favorite(user, activity.id)
end)
third_activity = Enum.at(activities, 2)
@@ -282,7 +282,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
7
|> insert_list(:note_activity)
|> Enum.each(fn activity ->
- CommonAPI.favorite(activity.id, user)
+ CommonAPI.favorite(user, activity.id)
end)
response =
@@ -320,7 +320,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
} do
user = insert(:user, hide_favorites: true)
activity = insert(:note_activity)
- CommonAPI.favorite(activity.id, user)
+ CommonAPI.favorite(user, activity.id)
conn =
conn
@@ -333,7 +333,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
test "hides favorites for new users by default", %{conn: conn, current_user: current_user} do
user = insert(:user)
activity = insert(:note_activity)
- CommonAPI.favorite(activity.id, user)
+ CommonAPI.favorite(user, activity.id)
conn =
conn
diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs
index 9b554601d..37c45eda6 100644
--- a/test/web/push/impl_test.exs
+++ b/test/web/push/impl_test.exs
@@ -161,7 +161,7 @@ defmodule Pleroma.Web.Push.ImplTest do
"<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
- {:ok, activity, _} = CommonAPI.favorite(activity.id, user)
+ {:ok, activity} = CommonAPI.favorite(user, activity.id)
object = Object.normalize(activity)
assert Impl.format_body(%{activity: activity}, user, object) == "@Bob has favorited your post"
diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs
index 8265f18dd..5a5b35147 100644
--- a/test/web/streamer/streamer_test.exs
+++ b/test/web/streamer/streamer_test.exs
@@ -69,7 +69,7 @@ defmodule Pleroma.Web.StreamerTest do
)
{:ok, activity} = CommonAPI.post(user, %{"status" => ":("})
- {:ok, notif, _} = CommonAPI.favorite(activity.id, blocked)
+ {:ok, notif} = CommonAPI.favorite(blocked, activity.id)
Streamer.stream("user:notification", notif)
Task.await(task)
@@ -88,7 +88,7 @@ defmodule Pleroma.Web.StreamerTest do
{:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
{:ok, activity} = CommonAPI.add_mute(user, activity)
- {:ok, notif, _} = CommonAPI.favorite(activity.id, user2)
+ {:ok, notif} = CommonAPI.favorite(user2, activity.id)
Streamer.stream("user:notification", notif)
Task.await(task)
end
@@ -106,7 +106,7 @@ defmodule Pleroma.Web.StreamerTest do
{:ok, user} = User.block_domain(user, "hecking-lewd-place.com")
{:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
- {:ok, notif, _} = CommonAPI.favorite(activity.id, user2)
+ {:ok, notif} = CommonAPI.favorite(user2, activity.id)
Streamer.stream("user:notification", notif)
Task.await(task)