Merge branch 'refactor/add-virtual-thread-muted-field' into 'develop'
Add virtual :thread_muted? field Closes #901 See merge request pleroma/pleroma!1178
This commit is contained in:
commit
d4847b17ca
6 changed files with 61 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.ActivityTest do
|
|||
use Pleroma.DataCase
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Bookmark
|
||||
alias Pleroma.ThreadMute
|
||||
import Pleroma.Factory
|
||||
|
||||
test "returns an activity by it's AP id" do
|
||||
|
|
@ -47,6 +48,31 @@ defmodule Pleroma.ActivityTest do
|
|||
assert queried_activity.bookmark == bookmark3
|
||||
end
|
||||
|
||||
test "setting thread_muted?" do
|
||||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
annoyed_user = insert(:user)
|
||||
{:ok, _} = ThreadMute.add_mute(annoyed_user.id, activity.data["context"])
|
||||
|
||||
activity_with_unset_thread_muted_field =
|
||||
Ecto.Query.from(Activity)
|
||||
|> Repo.one()
|
||||
|
||||
activity_for_user =
|
||||
Ecto.Query.from(Activity)
|
||||
|> Activity.with_set_thread_muted_field(user)
|
||||
|> Repo.one()
|
||||
|
||||
activity_for_annoyed_user =
|
||||
Ecto.Query.from(Activity)
|
||||
|> Activity.with_set_thread_muted_field(annoyed_user)
|
||||
|> Repo.one()
|
||||
|
||||
assert activity_with_unset_thread_muted_field.thread_muted? == nil
|
||||
assert activity_for_user.thread_muted? == false
|
||||
assert activity_for_annoyed_user.thread_muted? == true
|
||||
end
|
||||
|
||||
describe "getting a bookmark" do
|
||||
test "when association is loaded" do
|
||||
user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -902,7 +902,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
assert [activity] == ActivityPub.fetch_public_activities(%{}) |> Repo.preload(:bookmark)
|
||||
|
||||
assert [activity] ==
|
||||
assert [%{activity | thread_muted?: CommonAPI.thread_muted?(user2, activity)}] ==
|
||||
ActivityPub.fetch_activities([user2.ap_id | user2.following], %{"user" => user2})
|
||||
|
||||
{:ok, _user} = User.deactivate(user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue