Add status text to notifications (mentions and reposts)
This commit is contained in:
parent
dd5865535e
commit
cc7b35e097
7 changed files with 101 additions and 27 deletions
|
|
@ -23,7 +23,7 @@ defmodule Pleroma.Factory do
|
|||
}
|
||||
end
|
||||
|
||||
def note_factory do
|
||||
def note_factory(attrs \\ %{}) do
|
||||
text = sequence(:text, &"This is :moominmamma: note #{&1}")
|
||||
|
||||
user = insert(:user)
|
||||
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.Factory do
|
|||
}
|
||||
|
||||
%Pleroma.Object{
|
||||
data: data
|
||||
data: merge_attributes(data, Map.get(attrs, :data, %{}))
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -95,8 +95,8 @@ defmodule Pleroma.Factory do
|
|||
}
|
||||
end
|
||||
|
||||
def note_activity_factory do
|
||||
note = insert(:note)
|
||||
def note_activity_factory(attrs \\ %{}) do
|
||||
note = attrs[:note] || insert(:note)
|
||||
|
||||
data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
|
||||
|
|
@ -135,9 +135,9 @@ defmodule Pleroma.Factory do
|
|||
}
|
||||
end
|
||||
|
||||
def announce_activity_factory do
|
||||
note_activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
def announce_activity_factory(attrs \\ %{}) do
|
||||
note_activity = attrs[:note_activity] || insert(:note_activity)
|
||||
user = attrs[:user] || insert(:user)
|
||||
|
||||
data = %{
|
||||
"type" => "Announce",
|
||||
|
|
|
|||
53
test/web/push/push_test.exs
Normal file
53
test/web/push/push_test.exs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
defmodule Pleroma.Web.PushTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.Push
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "renders body for create activity" do
|
||||
assert Push.format_body(
|
||||
%{
|
||||
activity: %{
|
||||
data: %{
|
||||
"type" => "Create",
|
||||
"object" => %{
|
||||
"content" =>
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :bear: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
%{nickname: "Bob"}
|
||||
) ==
|
||||
"@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
|
||||
end
|
||||
|
||||
test "renders body for follow activity" do
|
||||
assert Push.format_body(%{activity: %{data: %{"type" => "Follow"}}}, %{nickname: "Bob"}) ==
|
||||
"@Bob has followed you"
|
||||
end
|
||||
|
||||
test "renders body for announce activity" do
|
||||
user = insert(:user)
|
||||
|
||||
note =
|
||||
insert(:note, %{
|
||||
data: %{
|
||||
"content" =>
|
||||
"<span>Lorem ipsum dolor sit amet</span>, consectetur :bear: adipiscing elit. Fusce sagittis finibus turpis."
|
||||
}
|
||||
})
|
||||
|
||||
note_activity = insert(:note_activity, %{note: note})
|
||||
announce_activity = insert(:announce_activity, %{user: user, note_activity: note_activity})
|
||||
|
||||
assert Push.format_body(%{activity: announce_activity}, user) ==
|
||||
"@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
|
||||
end
|
||||
|
||||
test "renders body for like activity" do
|
||||
assert Push.format_body(%{activity: %{data: %{"type" => "Like"}}}, %{nickname: "Bob"}) ==
|
||||
"@Bob has favorited your post"
|
||||
end
|
||||
end
|
||||
|
|
@ -1762,8 +1762,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/friendships/approve", %{"user_id" => other_user.id})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
|
||||
assert relationship = json_response(conn, 200)
|
||||
assert other_user.id == relationship["id"]
|
||||
assert relationship["follows_you"] == true
|
||||
|
|
@ -1787,8 +1785,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/friendships/deny", %{"user_id" => other_user.id})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
|
||||
assert relationship = json_response(conn, 200)
|
||||
assert other_user.id == relationship["id"]
|
||||
assert relationship["follows_you"] == false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue