summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2022-07-31 19:41:25 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2022-07-31 19:41:25 +0000
commitb5266097a1e73bd749d8176e327c14fcb9735f95 (patch)
treeb41591d09cb45c7d6ca545b3c858232277b51e40 /test
parent0814d0e0cb11ef82809babe34e4842f6c5676d70 (diff)
parent5d3d6a58f72888b8714605032b417091a8891bb4 (diff)
downloadpleroma-b5266097a1e73bd749d8176e327c14fcb9735f95.tar.gz
pleroma-b5266097a1e73bd749d8176e327c14fcb9735f95.zip
Merge branch 'mutes' into 'develop'
MastoAPI: Use `duration` param for mute expiration duration See merge request pleroma/pleroma!3715
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/user_test.exs2
-rw-r--r--test/pleroma/web/mastodon_api/controllers/account_controller_test.exs35
-rw-r--r--test/pleroma/web/mastodon_api/views/account_view_test.exs2
3 files changed, 37 insertions, 2 deletions
diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs
index 408389c3a..ce5510f24 100644
--- a/test/pleroma/user_test.exs
+++ b/test/pleroma/user_test.exs
@@ -1146,7 +1146,7 @@ defmodule Pleroma.UserTest do
user = insert(:user)
muted_user = insert(:user)
- {:ok, _user_relationships} = User.mute(user, muted_user, %{expires_in: 60})
+ {:ok, _user_relationships} = User.mute(user, muted_user, %{duration: 60})
assert User.mutes?(user, muted_user)
worker = Pleroma.Workers.MuteExpireWorker
diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
index ee9db4288..50639e246 100644
--- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
+ alias Pleroma.UserRelationship
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.InternalFetchActor
alias Pleroma.Web.CommonAPI
@@ -1011,6 +1012,40 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
assert %{"id" => _id, "muting" => false, "muting_notifications" => false} =
json_response_and_validate_schema(conn, 200)
end
+
+ test "expiring", %{conn: conn, user: user} do
+ other_user = insert(:user)
+
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/v1/accounts/#{other_user.id}/mute", %{"duration" => "86400"})
+
+ assert %{"id" => _id, "muting" => true} = json_response_and_validate_schema(conn, 200)
+
+ mute_expires_at = UserRelationship.get_mute_expire_date(user, other_user)
+
+ assert DateTime.diff(
+ mute_expires_at,
+ DateTime.utc_now() |> DateTime.add(24 * 60 * 60)
+ ) in -3..3
+ end
+
+ test "falls back to expires_in", %{conn: conn, user: user} do
+ other_user = insert(:user)
+
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/v1/accounts/#{other_user.id}/mute", %{"expires_in" => "86400"})
+ |> json_response_and_validate_schema(200)
+
+ mute_expires_at = UserRelationship.get_mute_expire_date(user, other_user)
+
+ assert DateTime.diff(
+ mute_expires_at,
+ DateTime.utc_now() |> DateTime.add(24 * 60 * 60)
+ ) in -3..3
+ end
end
describe "pinned statuses" do
diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs
index 8fa946d43..692ec8c92 100644
--- a/test/pleroma/web/mastodon_api/views/account_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs
@@ -640,7 +640,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
other_user = insert(:user)
{:ok, _user_relationships} =
- User.mute(user, other_user, %{notifications: true, expires_in: 24 * 60 * 60})
+ User.mute(user, other_user, %{notifications: true, duration: 24 * 60 * 60})
%{
mute_expires_at: mute_expires_at